diff options
author | Christian Segundo | 2024-12-08 13:06:41 +0100 |
---|---|---|
committer | Christian Segundo | 2024-12-08 13:06:41 +0100 |
commit | a459ffd8135d27499a616f5405468a1b20677223 (patch) | |
tree | 4a40f775e8f758d1c32636deb0b593de1ea14de4 /lua/plugins/lsp | |
parent | b0a97cff0312d0634442147bbe4a8c63c9e81e3d (diff) | |
download | config-a459ffd8135d27499a616f5405468a1b20677223.tar.gz |
misc stylua
Diffstat (limited to 'lua/plugins/lsp')
-rw-r--r-- | lua/plugins/lsp/cmp.lua | 194 | ||||
-rw-r--r-- | lua/plugins/lsp/config.lua | 88 | ||||
-rw-r--r-- | lua/plugins/lsp/null-ls.lua | 6 | ||||
-rw-r--r-- | lua/plugins/lsp/trouble.lua | 14 |
4 files changed, 155 insertions, 147 deletions
diff --git a/lua/plugins/lsp/cmp.lua b/lua/plugins/lsp/cmp.lua index 4b93ccf..890a813 100644 --- a/lua/plugins/lsp/cmp.lua +++ b/lua/plugins/lsp/cmp.lua @@ -1,102 +1,106 @@ return { - "hrsh7th/nvim-cmp", - opts = { - sources = { - { name = "ledger" }, - { - name = "luasnip", - option = { - show_autosnippets = true, - use_show_condition = true, - }, - }, - { name = "nvim_lsp", priority = 1 }, - { name = "nvim_lsp_signature_help" }, - { name = "nvim_lua" }, - { name = "path" }, - { name = "emoji" }, + "hrsh7th/nvim-cmp", + opts = { + sources = { + { name = "ledger" }, + { + name = "luasnip", + option = { + show_autosnippets = true, + use_show_condition = true, + }, + }, + { name = "nvim_lsp", priority = 1 }, + { name = "nvim_lsp_signature_help" }, + { name = "nvim_lua" }, + { name = "path" }, + { name = "emoji" }, }, { name = "abook" }, - format = { - mode = "symbol_text", - maxwidth = 50, - before = function(entry, vim_item) - return vim_item - end, - menu = { - buffer = "[Buffer]", - nvim_lsp = "[LSP]", - luasnip = "[LuaSnip]", - nvim_lua = "[Lua]", - latex_symbols = "[Latex]", - }, - }, + }, + formatting = { + format = { + mode = "symbol_text", + maxwidth = 50, + before = function(entry, vim_item) + return vim_item + end, + menu = { + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + luasnip = "[LuaSnip]", + nvim_lua = "[Lua]", + latex_symbols = "[Latex]", abook = "[Abook]", - }, - config = function(_, opts) - local cmp = require("cmp") - local luasnip = require("luasnip") - local lspkind = require("lspkind") - cmp.setup({ - sources = opts.sources, - --experimental = { ghost_text = { hl_group = "Comment" } }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - formatting = { format = lspkind.cmp_format(opts.formatting.format) }, - mapping = { - ["<C-p>"] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - ["<C-n>"] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - ["<C-l>"] = cmp.mapping(function(fallback) - if luasnip.choice_active() then - luasnip.change_choice(1) - else - fallback() - end - end, { "i", "s" }), - ["<C-d>"] = cmp.mapping.scroll_docs(-4), - ["<C-f>"] = cmp.mapping.scroll_docs(4), - ["<C-Space>"] = cmp.mapping.complete(), - ["<C-e>"] = cmp.mapping.close(), - ["<CR>"] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, -- Automatically select first item on CR - }), - }, - }) - end, - dependencies = { - { "L3MON4D3/LuaSnip" }, - { "hrsh7th/cmp-emoji" }, - { "hrsh7th/cmp-nvim-lsp" }, - { "hrsh7th/cmp-nvim-lsp-signature-help" }, - { "hrsh7th/cmp-nvim-lua" }, - { "hrsh7th/cmp-path" }, - { "onsails/lspkind.nvim" }, - { "saadparwaiz1/cmp_luasnip" }, - { "someone-stole-my-name/cmp-ledger" }, - }, + }, + }, + }, + }, + config = function(_, opts) + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + cmp.setup({ + sources = opts.sources, + --experimental = { ghost_text = { hl_group = "Comment" } }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + formatting = { format = lspkind.cmp_format(opts.formatting.format) }, + mapping = { + ["<C-p>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + ["<C-n>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + ["<C-l>"] = cmp.mapping(function(fallback) + if luasnip.choice_active() then + luasnip.change_choice(1) + else + fallback() + end + end, { "i", "s" }), + ["<C-d>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), + ["<C-e>"] = cmp.mapping.close(), + ["<CR>"] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, -- Automatically select first item on CR + }), + }, + }) + end, + dependencies = { + { "L3MON4D3/LuaSnip" }, + { "hrsh7th/cmp-emoji" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-nvim-lsp-signature-help" }, + { "hrsh7th/cmp-nvim-lua" }, + { "hrsh7th/cmp-path" }, + { "onsails/lspkind.nvim" }, + { "saadparwaiz1/cmp_luasnip" }, + { "someone-stole-my-name/cmp-ledger" }, { - -- Not sure how stable is this, but it works for now. The first element - -- always points to $HOME/.config/nvim - dir = vim.api.nvim_list_runtime_paths()[1] .. "/lua/plugins/dev/cmp-abook", + -- Not sure how stable is this, but it works for now. The first element + -- always points to $HOME/.config/nvim + dir = vim.api.nvim_list_runtime_paths()[1] + .. "/lua/plugins/dev/cmp-abook", }, + }, } diff --git a/lua/plugins/lsp/config.lua b/lua/plugins/lsp/config.lua index 579cfec..38aec3d 100644 --- a/lua/plugins/lsp/config.lua +++ b/lua/plugins/lsp/config.lua @@ -1,45 +1,49 @@ return { - { - "neovim/nvim-lspconfig", - event = { "BufReadPre", "BufNewFile" }, - opts = { servers = {} }, - config = function(_, opts) - local add_hook_after = require("lspconfig.util").add_hook_after - local on_attach = function(client, bufnr) - require("nvim-navic").attach(client, bufnr) - end + { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + opts = { servers = {} }, + config = function(_, opts) + local add_hook_after = require("lspconfig.util").add_hook_after + local on_attach = function(client, bufnr) + require("nvim-navic").attach(client, bufnr) + end - for lsp, lsp_opts in pairs(opts.servers) do - lsp_opts = lsp_opts or {} - if lsp_opts.on_attach ~= nil then - lsp_opts["on_attach"] = add_hook_after(on_attach, lsp_opts.on_attach) - end - lsp_opts["capabilities"] = require("cmp_nvim_lsp").default_capabilities( - lsp_opts.capabilities or {} - ) - require("lspconfig")[lsp].setup(lsp_opts) - end - end, - init = function() - vim.diagnostic.config({ - float = { - source = "always", - format = function(diagnostic) - -- should work for any LSP, see: https://github.com/neovim/neovim/pull/17510 - if diagnostic.code then - return string.format( - "(%s) %s", - diagnostic.code, - diagnostic.message - ) - end - return diagnostic.message - end, - }, - }) - end, - dependencies = { - { "SmiteshP/nvim-navic", opts = { highlight = true } }, - }, - }, + for lsp, lsp_opts in pairs(opts.servers) do + lsp_opts = lsp_opts or {} + if lsp_opts.on_attach ~= nil then + lsp_opts["on_attach"] = + add_hook_after(on_attach, lsp_opts.on_attach) + end + lsp_opts["capabilities"] = + require("cmp_nvim_lsp").default_capabilities( + lsp_opts.capabilities or {} + ) + lsp_opts.capabilities.textDocument.completion.completionItem.snippetSupport = + true + require("lspconfig")[lsp].setup(lsp_opts) + end + end, + init = function() + vim.diagnostic.config({ + float = { + source = "always", + format = function(diagnostic) + -- should work for any LSP, see: https://github.com/neovim/neovim/pull/17510 + if diagnostic.code then + return string.format( + "(%s) %s", + diagnostic.code, + diagnostic.message + ) + end + return diagnostic.message + end, + }, + }) + end, + dependencies = { + { "SmiteshP/nvim-navic", opts = { highlight = true } }, + }, + }, } diff --git a/lua/plugins/lsp/null-ls.lua b/lua/plugins/lsp/null-ls.lua index 5f71af7..f530586 100644 --- a/lua/plugins/lsp/null-ls.lua +++ b/lua/plugins/lsp/null-ls.lua @@ -1,5 +1,5 @@ return { - "jose-elias-alvarez/null-ls.nvim", - opts = { sources = {}, debug = false }, - dependencies = { "nvim-lua/plenary.nvim" }, + "jose-elias-alvarez/null-ls.nvim", + opts = { sources = {}, debug = false }, + dependencies = { "nvim-lua/plenary.nvim" }, } diff --git a/lua/plugins/lsp/trouble.lua b/lua/plugins/lsp/trouble.lua index 207edb5..e63ae22 100644 --- a/lua/plugins/lsp/trouble.lua +++ b/lua/plugins/lsp/trouble.lua @@ -1,9 +1,9 @@ return { - { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - require("trouble").setup({}) - end, - }, + { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("trouble").setup({}) + end, + }, } |