diff options
| author | Zach Berwaldt <zberwaldt@tutamail.com> | 2023-09-25 18:59:27 -0400 |
|---|---|---|
| committer | Zach Berwaldt <zberwaldt@tutamail.com> | 2023-09-25 18:59:27 -0400 |
| commit | 624620c918c4d9590f177290e27f469b4778d63f (patch) | |
| tree | 5715f0fd70470bad983a8d134ecadc2f7f0b4aec /after/plugin | |
| parent | fb6d08dabb1f500aac84be26fc10185b60a30820 (diff) | |
add lsp config
Diffstat (limited to 'after/plugin')
| -rw-r--r-- | after/plugin/lsp.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua new file mode 100644 index 0000000..3e61be0 --- /dev/null +++ b/after/plugin/lsp.lua | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | local lsp = require("lsp-zero") | ||
| 2 | |||
| 3 | lsp.preset("recommended") | ||
| 4 | |||
| 5 | lsp.on_attach(function(client, bufnr) | ||
| 6 | local opts = { buffer = bufnr, remap = false } | ||
| 7 | |||
| 8 | vim.keymap.set("n", "gd", function () vim.lsp.buf.definition() end, opts) | ||
| 9 | |||
| 10 | lsp.default_keymaps({buffer = bufnr}) | ||
| 11 | end) | ||
| 12 | |||
| 13 | require('mason').setup({}) | ||
| 14 | require('mason-lspconfig').setup({ | ||
| 15 | -- Replace the language servers listed here | ||
| 16 | -- with the ones you want to install | ||
| 17 | ensure_installed = {'tsserver', 'eslint', 'sumneko_lua', 'rust_analyzer'}, | ||
| 18 | handlers = { | ||
| 19 | lsp.default_setup, | ||
| 20 | }, | ||
| 21 | }) | ||
| 22 | |||
| 23 | local cmp = require('cmp') | ||
| 24 | local cmp_select = {behavior = cmp.SelectBehavior.Select} | ||
| 25 | local cmp_mappings = lsp.defaults.cmp_mappings({ | ||
| 26 | ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), | ||
| 27 | ['<C-n>'] = cmp.mapping.select_next_item(cmp_select), | ||
| 28 | ['<C-y>'] = cmp.mapping.confirm({ select = true }), | ||
| 29 | ["<C-Space>"] = cmp.mapping.complete(), | ||
| 30 | }) | ||
| 31 | |||
| 32 | lsp.set_preferences({ | ||
| 33 | sign_icons = { } | ||
| 34 | }) | ||
