summaryrefslogtreecommitdiff
path: root/lua/plugins
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-05-23 18:39:08 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2024-05-23 18:39:08 -0400
commitec5b7931bee6432dd30ad943518f603af53a15e0 (patch)
tree0f38069303aca9ebc531ca53d49c21bbe8184ff6 /lua/plugins
parent62f2dd728daeaa29dead8e94f8cb996435b038cf (diff)
Trying Prime's LSP config
Diffstat (limited to 'lua/plugins')
-rw-r--r--lua/plugins/lsp.lua103
1 files changed, 103 insertions, 0 deletions
diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua
new file mode 100644
index 0000000..ffb48fa
--- /dev/null
+++ b/lua/plugins/lsp.lua
@@ -0,0 +1,103 @@
+return {
+ "neovim/nvim-lspconfig",
+ dependencies = {
+ "williamboman/mason.nvim",
+ "williamboman/mason-lspconfig.nvim",
+ "hrsh7th/cmp-nvim-lsp",
+ "hrsh7th/cmp-buffer",
+ "hrsh7th/cmp-path",
+ "hrsh7th/cmp-cmdline",
+ "hrsh7th/nvim-cmp",
+ "L3MON4D3/LuaSnip",
+ "saadparwaiz1/cmp_luasnip",
+ "j-hui/fidget.nvim",
+ },
+
+ config = function()
+ local cmp = require('cmp')
+ local cmp_lsp = require("cmp_nvim_lsp")
+ local capabilities = vim.tbl_deep_extend(
+ "force",
+ {},
+ vim.lsp.protocol.make_client_capabilities(),
+ cmp_lsp.default_capabilities())
+
+ require("fidget").setup({})
+ require("mason").setup()
+ require("mason-lspconfig").setup({
+ ensure_installed = {
+ "vimls",
+ "lua_ls",
+
+ "gopls",
+ "golangci_lint_ls",
+
+ "sqlls",
+ "dockerls",
+ "docker_compose_language_service",
+
+ "graphql",
+ "yamlls",
+
+ "rust_analyzer",
+ "clangd",
+ },
+ handlers = {
+ function(server_name) -- default handler (optional)
+
+ require("lspconfig")[server_name].setup {
+ capabilities = capabilities
+ }
+ end,
+
+ ["lua_ls"] = function()
+ local lspconfig = require("lspconfig")
+ lspconfig.lua_ls.setup {
+ capabilities = capabilities,
+ settings = {
+ Lua = {
+ runtime = { version = "Lua 5.1" },
+ diagnostics = {
+ globals = { "vim", "it", "describe", "before_each", "after_each" },
+ }
+ }
+ }
+ }
+ end,
+ }
+ })
+
+ local cmp_select = { behavior = cmp.SelectBehavior.Select }
+
+ cmp.setup({
+ snippet = {
+ expand = function(args)
+ require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
+ end,
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
+ ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
+ ['<C-y>'] = cmp.mapping.confirm({ select = true }),
+ ["<C-Space>"] = cmp.mapping.complete(),
+ }),
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ { name = 'luasnip' }, -- For luasnip users.
+ }, {
+ { name = 'buffer' },
+ })
+ })
+
+ vim.diagnostic.config({
+ float = {
+ focusable = false,
+ style = "minimal",
+ border = "rounded",
+ source = "always",
+ header = "",
+ prefix = "",
+ },
+ })
+ end
+}