diff options
Diffstat (limited to 'lua/config')
| -rw-r--r-- | lua/config/editor.lua | 25 | ||||
| -rw-r--r-- | lua/config/lsp.lua | 114 | ||||
| -rw-r--r-- | lua/config/packer.lua | 57 |
3 files changed, 61 insertions, 135 deletions
diff --git a/lua/config/editor.lua b/lua/config/editor.lua index eec0e08..0649006 100644 --- a/lua/config/editor.lua +++ b/lua/config/editor.lua | |||
| @@ -1,10 +1,6 @@ | |||
| 1 | local js_based_languages = { "typescript", "javascript", "typescriptreact", "javascriptreact" } | ||
| 2 | local option = vim.opt | 1 | local option = vim.opt |
| 3 | local keymap = vim.keymap | 2 | local keymap = vim.keymap |
| 4 | 3 | ||
| 5 | local telescope = require("telescope.builtin") | ||
| 6 | local autotag = require("nvim-ts-autotag").setup() | ||
| 7 | |||
| 8 | --Basic Editor Setup | 4 | --Basic Editor Setup |
| 9 | option.nu = true | 5 | option.nu = true |
| 10 | option.tabstop = 2 | 6 | option.tabstop = 2 |
| @@ -21,13 +17,15 @@ option.laststatus = 0 | |||
| 21 | option.signcolumn = "number" | 17 | option.signcolumn = "number" |
| 22 | option.autoindent = true | 18 | option.autoindent = true |
| 23 | option.clipboard = "unnamedplus" | 19 | option.clipboard = "unnamedplus" |
| 24 | option.termguicolors = true | 20 | option.termguicolors = false |
| 21 | option.fillchars = 'eob: ' | ||
| 25 | 22 | ||
| 26 | -- Setup Editor Theme | 23 | -- Setup Editor Theme |
| 27 | vim.cmd.colorscheme("tokyonight") | ||
| 28 | vim.cmd([[ | 24 | vim.cmd([[ |
| 29 | highlight GitGutterAdd ctermbg=none | 25 | highlight GitGutterAdd ctermbg=none |
| 30 | highlight GitGutterAdd guibg=none | 26 | highlight GitGutterAdd guibg=none |
| 27 | highlight NonText guifg=none | ||
| 28 | highlight EndOfBuffer ctermfg=none ctermbg=none | ||
| 31 | highlight Normal ctermbg=none | 29 | highlight Normal ctermbg=none |
| 32 | highlight Normal guibg=none | 30 | highlight Normal guibg=none |
| 33 | highlight signcolumn ctermbg=none | 31 | highlight signcolumn ctermbg=none |
| @@ -62,7 +60,6 @@ highlight DiagnosticVirtualTextHint ctermbg=none | |||
| 62 | highlight DiagnosticVirtualTextHint guibg=none | 60 | highlight DiagnosticVirtualTextHint guibg=none |
| 63 | ]]) | 61 | ]]) |
| 64 | 62 | ||
| 65 | |||
| 66 | -- run specific commands after different file extensions | 63 | -- run specific commands after different file extensions |
| 67 | vim.cmd([[ | 64 | vim.cmd([[ |
| 68 | augroup RunPfOnSave | 65 | augroup RunPfOnSave |
| @@ -83,21 +80,7 @@ vim.g.gitgutter_set_sign_backgrounds = 1 | |||
| 83 | --Keybinds | 80 | --Keybinds |
| 84 | vim.g.mapleader = " " | 81 | vim.g.mapleader = " " |
| 85 | keymap.set("n", "<leader>e", vim.cmd.Ex) | 82 | keymap.set("n", "<leader>e", vim.cmd.Ex) |
| 86 | keymap.set("n", "<leader>f", telescope.find_files, {}) | ||
| 87 | keymap.set("n", "<leader>fg", telescope.live_grep, {}) | ||
| 88 | keymap.set("n", "<leader>fb", telescope.buffers, {}) | ||
| 89 | keymap.set("n", "<leader>fh", telescope.help_tags, {}) | ||
| 90 | keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) | 83 | keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) |
| 91 | keymap.set("n", "<leader>a", "ggVG") | 84 | keymap.set("n", "<leader>a", "ggVG") |
| 92 | keymap.set("v", "J", ":m '>+1<CR>gv=gv") | 85 | keymap.set("v", "J", ":m '>+1<CR>gv=gv") |
| 93 | keymap.set("v", "K", ":m '<-2<CR>gv=gv") | 86 | keymap.set("v", "K", ":m '<-2<CR>gv=gv") |
| 94 | |||
| 95 | --Treesitter | ||
| 96 | require("nvim-treesitter.configs").setup({ | ||
| 97 | ensure_installed = { "javascript", "typescript", "rust", "c", "lua", "vim" }, | ||
| 98 | sync_install = false, | ||
| 99 | auto_install = true, | ||
| 100 | highlight = { | ||
| 101 | enable = true, | ||
| 102 | }, | ||
| 103 | }) | ||
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index ca341d5..7fd0ddb 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua | |||
| @@ -1,64 +1,64 @@ | |||
| 1 | -- local lsp = require('lsp-zero') | 1 | -- local lsp = require('lsp-zero') |
| 2 | 2 | ||
| 3 | local lsp_zero = require("lsp-zero") | 3 | --local lsp_zero = require("lsp-zero") |
| 4 | local cmp = require("cmp") | 4 | --local cmp = require("cmp") |
| 5 | require("luasnip.loaders.from_vscode").lazy_load() | 5 | --require("luasnip.loaders.from_vscode").lazy_load() |
| 6 | 6 | ||
| 7 | lsp_zero.preset("recommended") | 7 | --lsp_zero.preset("recommended") |
| 8 | lsp_zero.setup() | 8 | --lsp_zero.setup() |
| 9 | lsp_zero.on_attach(function(client_id, bufnr) | 9 | --lsp_zero.on_attach(function(client_id, bufnr) |
| 10 | lsp_zero.default_keymaps({ buffer = bufnr }) | 10 | -- lsp_zero.default_keymaps({ buffer = bufnr }) |
| 11 | end) | 11 | --end) |
| 12 | 12 | ||
| 13 | require("mason").setup({}) | 13 | --require("mason").setup({}) |
| 14 | require("mason-lspconfig").setup({ | 14 | --require("mason-lspconfig").setup({ |
| 15 | ensure_installed = { "clangd", "rust_analyzer" }, | 15 | -- ensure_installed = { "clangd", "rust_analyzer" }, |
| 16 | handlers = { | 16 | -- handlers = { |
| 17 | lsp_zero.default_setup, | 17 | -- lsp_zero.default_setup, |
| 18 | }, | 18 | -- }, |
| 19 | }) | 19 | --}) |
| 20 | 20 | ||
| 21 | cmp.setup({ | 21 | --cmp.setup({ |
| 22 | snippet = { | 22 | -- snippet = { |
| 23 | expand = function(args) | 23 | -- expand = function(args) |
| 24 | require("luasnip").lsp_expand(args.body) | 24 | -- require("luasnip").lsp_expand(args.body) |
| 25 | end, | 25 | -- end, |
| 26 | }, | 26 | -- }, |
| 27 | window = {}, | 27 | -- window = {}, |
| 28 | mapping = cmp.mapping.preset.insert({ | 28 | -- mapping = cmp.mapping.preset.insert({ |
| 29 | ["<C-b>"] = cmp.mapping.scroll_docs(-4), | 29 | -- ["<C-b>"] = cmp.mapping.scroll_docs(-4), |
| 30 | ["<C-f>"] = cmp.mapping.scroll_docs(4), | 30 | -- ["<C-f>"] = cmp.mapping.scroll_docs(4), |
| 31 | ["<C-Space>"] = cmp.mapping.complete(), | 31 | -- ["<C-Space>"] = cmp.mapping.complete(), |
| 32 | ["<C-e>"] = cmp.mapping.abort(), | 32 | -- ["<C-e>"] = cmp.mapping.abort(), |
| 33 | ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. | 33 | -- ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. |
| 34 | }), | 34 | -- }), |
| 35 | sources = cmp.config.sources({ | 35 | -- sources = cmp.config.sources({ |
| 36 | { name = "nvim_lsp" }, | 36 | -- { name = "nvim_lsp" }, |
| 37 | { name = "luasnip" }, | 37 | -- { name = "luasnip" }, |
| 38 | }, { | 38 | -- }, { |
| 39 | { name = "buffer" }, | 39 | -- { name = "buffer" }, |
| 40 | }), | 40 | -- }), |
| 41 | }) | 41 | --}) |
| 42 | 42 | ||
| 43 | function PrintDiagnostics(opts, bufnr, line_nr, client_id) | 43 | --function PrintDiagnostics(opts, bufnr, line_nr, client_id) |
| 44 | bufnr = bufnr or 0 | 44 | -- bufnr = bufnr or 0 |
| 45 | line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) | 45 | -- line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) |
| 46 | opts = opts or { ["lnum"] = line_nr } | 46 | -- opts = opts or { ["lnum"] = line_nr } |
| 47 | -- | ||
| 48 | -- local line_diagnostics = vim.diagnostic.get(bufnr, opts) | ||
| 49 | -- if vim.tbl_isempty(line_diagnostics) then | ||
| 50 | -- return | ||
| 51 | -- end | ||
| 52 | -- | ||
| 53 | -- local diagnostic_message = "" | ||
| 54 | -- for i, diagnostic in ipairs(line_diagnostics) do | ||
| 55 | -- diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") | ||
| 56 | -- print(diagnostic_message) | ||
| 57 | -- if i ~= #line_diagnostics then | ||
| 58 | -- diagnostic_message = diagnostic_message .. "\n" | ||
| 59 | -- end | ||
| 60 | -- end | ||
| 61 | -- vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) | ||
| 62 | --end | ||
| 47 | 63 | ||
| 48 | local line_diagnostics = vim.diagnostic.get(bufnr, opts) | 64 | --vim.cmd([[ autocmd! CursorHold * lua PrintDiagnostics() ]]) |
| 49 | if vim.tbl_isempty(line_diagnostics) then | ||
| 50 | return | ||
| 51 | end | ||
| 52 | |||
| 53 | local diagnostic_message = "" | ||
| 54 | for i, diagnostic in ipairs(line_diagnostics) do | ||
| 55 | diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") | ||
| 56 | print(diagnostic_message) | ||
| 57 | if i ~= #line_diagnostics then | ||
| 58 | diagnostic_message = diagnostic_message .. "\n" | ||
| 59 | end | ||
| 60 | end | ||
| 61 | vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) | ||
| 62 | end | ||
| 63 | |||
| 64 | vim.cmd([[ autocmd! CursorHold * lua PrintDiagnostics() ]]) | ||
diff --git a/lua/config/packer.lua b/lua/config/packer.lua deleted file mode 100644 index 07a600a..0000000 --- a/lua/config/packer.lua +++ /dev/null | |||
| @@ -1,57 +0,0 @@ | |||
| 1 | vim.cmd([[packadd packer.nvim]]) | ||
| 2 | return require("packer").startup(function(use) | ||
| 3 | use("wbthomason/packer.nvim") | ||
| 4 | use("nvim-treesitter/nvim-treesitter") | ||
| 5 | use("neovim/nvim-lspconfig") | ||
| 6 | use("lukas-reineke/indent-blankline.nvim") | ||
| 7 | use("lervag/vimtex") | ||
| 8 | use("folke/tokyonight.nvim") | ||
| 9 | use("airblade/vim-gitgutter") | ||
| 10 | use("jose-elias-alvarez/null-ls.nvim") | ||
| 11 | use("windwp/nvim-ts-autotag") | ||
| 12 | use({ | ||
| 13 | "nvim-telescope/telescope.nvim", | ||
| 14 | tag = "0.1.4", | ||
| 15 | requires = { { "nvim-lua/plenary.nvim" } }, | ||
| 16 | }) | ||
| 17 | use({ | ||
| 18 | "VonHeikemen/lsp-zero.nvim", | ||
| 19 | requires = { | ||
| 20 | { "neovim/nvim-lspconfig" }, | ||
| 21 | { "williamboman/mason.nvim" }, | ||
| 22 | { "williamboman/mason-lspconfig.nvim" }, | ||
| 23 | { "hrsh7th/nvim-cmp" }, | ||
| 24 | { "hrsh7th/cmp-buffer" }, | ||
| 25 | { "hrsh7th/cmp-path" }, | ||
| 26 | { "saadparwaiz1/cmp_luasnip" }, | ||
| 27 | { "hrsh7th/cmp-nvim-lsp" }, | ||
| 28 | { "hrsh7th/cmp-nvim-lua" }, | ||
| 29 | { "rafamadriz/friendly-snippets" }, | ||
| 30 | }, | ||
| 31 | }) | ||
| 32 | use({ | ||
| 33 | "L3MON4D3/LuaSnip", | ||
| 34 | tag = "v2.*", | ||
| 35 | run = "make install_jsregexp", | ||
| 36 | }) | ||
| 37 | use({ | ||
| 38 | "numToStr/Comment.nvim", | ||
| 39 | config = function() | ||
| 40 | require("Comment").setup() | ||
| 41 | end, | ||
| 42 | }) | ||
| 43 | use({ | ||
| 44 | "iamcco/markdown-preview.nvim", | ||
| 45 | run = "cd app && npm install", | ||
| 46 | setup = function() | ||
| 47 | vim.g.mkdp_filetypes = { "markdown" } | ||
| 48 | end, | ||
| 49 | ft = { "markdown" }, | ||
| 50 | }) | ||
| 51 | use({ | ||
| 52 | "windwp/nvim-autopairs", | ||
| 53 | config = function() | ||
| 54 | require("nvim-autopairs").setup({}) | ||
| 55 | end, | ||
| 56 | }) | ||
| 57 | end) | ||
