diff options
Diffstat (limited to '.config/nvim/lua/chronoziel/plugins/lsp-zero.lua')
-rw-r--r-- | .config/nvim/lua/chronoziel/plugins/lsp-zero.lua | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/.config/nvim/lua/chronoziel/plugins/lsp-zero.lua b/.config/nvim/lua/chronoziel/plugins/lsp-zero.lua new file mode 100644 index 0000000..dd58ee4 --- /dev/null +++ b/.config/nvim/lua/chronoziel/plugins/lsp-zero.lua @@ -0,0 +1,168 @@ +return { + "VonHeikemen/lsp-zero.nvim", + + dependencies = { + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + + {'neovim/nvim-lspconfig'}, + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-nvim-lsp'}, + }, + + config = function() + -- "Avoids annoying layout shift in the screen" + vim.opt.signcolumn = 'yes' + + -- Adds cmp_nvim_lsp capabilities settings to lspconfig + local lspconfig_defaults = require('lspconfig').util.default_config + lspconfig_defaults.capabilities = vim.tbl_deep_extend( + 'force', + lspconfig_defaults.capabilities, + require('cmp_nvim_lsp').default_capabilities() + ) + + -- This is where you enable features that only work + -- if there is a language server active in the file + vim.api.nvim_create_autocmd('LspAttach', { + desc = 'LSP actions', + callback = function(event) + local opts = {buffer = event.buf} + + vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts) + vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts) + vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts) + vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts) + vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts) + vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts) + vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts) + vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts) + vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts) + vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts) + end, + }) + + -- to learn how to use mason.nvim + -- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md + require('mason').setup({}) + + require('mason-lspconfig').setup({ + ensure_installed = {}, + handlers = { + function(server_name) + require('lspconfig')[server_name].setup({}) + end, + }, + }) + + require('lspconfig').harper_ls.setup { + settings = { + ["harper-ls"] = { + linters = { + spell_check = false, + spelled_numbers = false, + an_a = true, + sentence_capitalization = false, + unclosed_quotes = true, + wrong_quotes = false, + long_sentences = false, + repeated_words = false, + spaces = true, + matcher = true, + correct_number_suffix = true, + number_suffix_capitalization = true, + multiple_sequential_pronouns = true, + linking_verbs = false, + avoid_curses = false, + terminating_conjunctions = true + } + } + }, + } + + local cmp = require('cmp') + + cmp.setup({ + sources = { + {name = 'nvim_lsp'}, + }, + snippet = { + expand = function(args) + -- You need Neovim v0.10 to use vim.snippet + vim.snippet.expand(args.body) + end, + }, +-- mapping = cmp.mapping.preset.insert({}), + + mapping = { + ["<Tab>"] = cmp.mapping.select_next_item(), + ["<S-Tab>"] = cmp.mapping.select_prev_item(), + ["<C-Tab>"] = cmp.mapping.complete(), + } + + }) + + + end, + + -- "VonHeikemen/lsp-zero.nvim", + -- dependencies = { + -- {'williamboman/mason.nvim'}, + -- {'williamboman/mason-lspconfig.nvim'}, + -- + -- {'neovim/nvim-lspconfig'}, + -- {'hrsh7th/nvim-cmp'}, + -- {'hrsh7th/cmp-nvim-lsp'}, + -- + -- {'L3MON4D3/LuaSnip'}, + -- }, + -- + -- config = function() + -- local lsp_zero = require('lsp-zero') + -- + -- lsp_zero.on_attach(function(client, bufnr) + -- -- see :help lsp-zero-keybindings + -- -- to learn the available actions + -- lsp_zero.default_keymaps({buffer = bufnr}) + -- end) + -- + -- + -- -- to learn how to use mason.nvim + -- -- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md + -- require('mason').setup({}) + -- + -- require('mason-lspconfig').setup({ + -- ensure_installed = {}, + -- handlers = { + -- function(server_name) + -- require('lspconfig')[server_name].setup({}) + -- end, + -- }, + -- }) + -- + -- require('lspconfig').harper_ls.setup { + -- settings = { + -- ["harper-ls"] = { + -- linters = { + -- spell_check = false, + -- spelled_numbers = false, + -- an_a = true, + -- sentence_capitalization = false, + -- unclosed_quotes = true, + -- wrong_quotes = false, + -- long_sentences = false, + -- repeated_words = false, + -- spaces = true, + -- matcher = true, + -- correct_number_suffix = true, + -- number_suffix_capitalization = true, + -- multiple_sequential_pronouns = true, + -- linking_verbs = false, + -- avoid_curses = false, + -- terminating_conjunctions = true + -- } + -- } + -- }, + -- } + -- end + } |