diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2023-04-10 18:59:40 +0200 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2023-04-10 18:59:40 +0200 |
commit | ed6b8049bd7040e2c2a72f78ba0a0ed000604340 (patch) | |
tree | ded0d7014967abb0b4c7db1ff6582d54d4eeff0f /lua | |
parent | 23959a977ff6b6cc1165f5489c88bc62f39b3ec2 (diff) |
lsp stuff
Diffstat (limited to 'lua')
-rw-r--r-- | lua/lsp.lua | 62 | ||||
-rw-r--r-- | lua/packages.lua | 24 |
2 files changed, 56 insertions, 30 deletions
diff --git a/lua/lsp.lua b/lua/lsp.lua index 7d34725..54337eb 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,6 +1,38 @@ -local lsp = require("lsp-zero").preset({}) +require("mason").setup() -lsp.on_attach(function(client, b) +require("mason-lspconfig").setup({ + ensure_installed = { "clangd" }, +}) + +local cmp = require("cmp") +cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + sources = cmp.config.sources({ + { + name = "nvim_lsp", + entry_filter = function(entry, ctx) + if entry:get_kind() == 15 then -- Snippet + print("OH NO") + return false + end + return true + end, + }, + }), + mapping = cmp.mapping.preset.insert({ + ['<cr>'] = cmp.mapping.confirm({ select = true }), + ['<esc>'] = cmp.mapping.abort(), + }) +}) + +local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities() +lsp_capabilities.textDocument.completion.completionItem.snipperSupport = false + +local lsp_on_attach = function(client, b) local nmap = function(keys, func, desc) vim.keymap.set("n", keys, func, { buffer = b, desc = desc }) end @@ -11,22 +43,22 @@ lsp.on_attach(function(client, b) nmap("<leader>fr", require("telescope.builtin").lsp_references, "Find references") nmap("<c-o>", require("telescope.builtin").lsp_document_symbols, "Find document symbols") nmap("<c-h>", vim.lsp.buf.hover, "Signature help") -end) +end -lsp.ensure_installed({ - "clangd", -}) +local lspconfig = require("lspconfig") -require("lspconfig").clangd.setup({ - cmd = { "C:\\Program Files\\LLVM-15\\bin\\clangd.exe" }, +require("mason-lspconfig").setup_handlers({ + function (server_name) + lspconfig[server_name].setup({ + on_attach = lsp_on_attach, + capabilities = lsp_capabilities, + }) + end }) -lsp.setup() - -require("cmp").setup({ - mapping = { - ['<cr>'] = require("cmp").mapping.confirm({ select = true }), - ['<esc>'] = require("cmp").mapping.abort(), - } +lspconfig.clangd.setup({ + on_attach = lsp_on_attach, + capabilities = lsp_capabilities, + cmd = { "C:\\Program Files\\LLVM-15\\bin\\clangd.exe" }, }) diff --git a/lua/packages.lua b/lua/packages.lua index c98ba8e..052496d 100644 --- a/lua/packages.lua +++ b/lua/packages.lua @@ -34,23 +34,17 @@ require("lazy").setup({ }, build = ":TSUpdate", }, + {"neovim/nvim-lspconfig"}, { - "VonHeikemen/lsp-zero.nvim", - branch = "v2.x", - dependencies = { - {"neovim/nvim-lspconfig"}, - { - "williamboman/mason.nvim", - build = function() - pcall(vim.cmd, "MasonUpdate") - end, - }, - { "williamboman/mason-lspconfig.nvim" }, - { "hrsh7th/nvim-cmp" }, - { "hrsh7th/cmp-nvim-lsp" }, - { "L3MON4D3/LuaSnip" }, - }, + "williamboman/mason.nvim", + build = function() + pcall(vim.cmd, "MasonUpdate") + end, }, + { "williamboman/mason-lspconfig.nvim" }, + { "hrsh7th/nvim-cmp" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "L3MON4D3/LuaSnip" }, { "lukas-reineke/indent-blankline.nvim", }, |