nvim: Prepare lsp-zero switch to v2 branch
Switched the configuration of lsp-zero to its less integrated v2 version. Switched back to manually configuring most of nvim-cmp. Addded some manual formatting to cmp which displays completion kind as icons not as text. Manually add luasnip integration.
This commit is contained in:
parent
39b495affd
commit
6b28e6417b
3 changed files with 168 additions and 41 deletions
|
@ -4,13 +4,17 @@
|
|||
"LuaSnip": { "branch": "master", "commit": "500981ff6cefc7343e3959ef0f939bd0bfd49ba9" },
|
||||
"Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
|
||||
"bats.vim": { "branch": "master", "commit": "6a5d2ef22b0ede503d867770afd02ebb1f97b709" },
|
||||
"cmp-beancount": { "branch": "main", "commit": "da154ea94d598e6649d6ad01efa0a8611eff460d" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-calc": { "branch": "main", "commit": "50792f34a628ea6eb31d2c90e8df174671e4e7a0" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "8fcc934a52af96120fe26358985c10c035984b53" },
|
||||
"cmp-digraphs": { "branch": "master", "commit": "5efc1f0078d7c5f3ea1c8e3aad04da3fd6e081a9" },
|
||||
"cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
|
||||
"cmp-nvim-lua": { "branch": "main", "commit": "f3491638d123cfd2c8048aefaf66d246ff250ca6" },
|
||||
"cmp-pandoc-references": { "branch": "master", "commit": "2c808dff631a783ddd2c554c4c6033907589baf6" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp-rg": { "branch": "master", "commit": "1cad8eb315643d0df13c37401c03d7986f891011" },
|
||||
"cmp-spell": { "branch": "master", "commit": "60584cb75e5e8bba5a0c9e4c3ab0791e0698bffa" },
|
||||
"cmp-tmux": { "branch": "main", "commit": "984772716f66d8ee88535a6bf3f94c4b4e1301f5" },
|
||||
"cmp-treesitter": { "branch": "master", "commit": "b40178b780d547bcf131c684bc5fd41af17d05f2" },
|
||||
|
@ -27,13 +31,13 @@
|
|||
"lazy.nvim": { "branch": "main", "commit": "887eb75591520a01548134c4623617b639289d0b" },
|
||||
"lightspeed.nvim": { "branch": "main", "commit": "299eefa6a9e2d881f1194587c573dad619fdb96f" },
|
||||
"lsp-format.nvim": { "branch": "master", "commit": "ca0df5c8544e51517209ea7b86ecc522c98d4f0a" },
|
||||
"lsp-zero.nvim": { "branch": "main", "commit": "5b68fbdc91102de41fb53da79f52752370d71a7e" },
|
||||
"lsp-zero.nvim": { "branch": "v2.x", "commit": "7cb74b241c9d99b5d44f2111696cd9306848b25b" },
|
||||
"lsp_signature.nvim": { "branch": "master", "commit": "4665921ff8e30601c7c1328625b3abc1427a6143" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" },
|
||||
"magma-nvim-goose": { "branch": "main", "commit": "5d916c39c1852e09fcd39eab174b8e5bbdb25f8f" },
|
||||
"markdown-preview.nvim": { "branch": "master", "commit": "9becceee5740b7db6914da87358a183ad11b2049" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "a31e011135a79d63c71254c250c9158e1056a1cb" },
|
||||
"mason.nvim": { "branch": "main", "commit": "3ee3174e30e33c9d58fa07b0a73a6e180474b59c" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "2b811031febe5f743e07305738181ff367e1e452" },
|
||||
"mason.nvim": { "branch": "main", "commit": "a192887fd0c29275cf2acb4a83bcbdf63399f8df" },
|
||||
"mini.nvim": { "branch": "main", "commit": "427751024313e2270ca723eb16af7b218c83a7fc" },
|
||||
"neural": { "branch": "main", "commit": "155618730b87a67655bdde373ee27bfce8b07ac9" },
|
||||
"nui.nvim": { "branch": "main", "commit": "0dc148c6ec06577fcf06cbab3b7dac96d48ba6be" },
|
||||
|
@ -45,7 +49,7 @@
|
|||
"nvim-surround": { "branch": "main", "commit": "b98862527c4727c171f8626e04d8ae88ef6cb736" },
|
||||
"nvim-toggleterm.lua": { "branch": "main", "commit": "a5638b2206c3930a16a24e5c184dddd572f8cd34" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "c38646edf2bdfac157ca619697ecad9ea87fd469" },
|
||||
"nvim-treesitter-context": { "branch": "master", "commit": "895ec44f5c89bc67ba5440aef3d1f2efa3d59a41" },
|
||||
"nvim-treesitter-context": { "branch": "master", "commit": "88d1627285f7477883516ef60521601862dae7a1" },
|
||||
"nvim-treesitter-textsubjects": { "branch": "master", "commit": "b913508f503527ff540f7fe2dcf1bf1d1f259887" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "729d83ecb990dc2b30272833c213cc6d49ed5214" },
|
||||
"nvim-ts-rainbow2": { "branch": "master", "commit": "cee4601ff8aac73dee4afa1074814343bb5a0b80" },
|
||||
|
|
|
@ -2,13 +2,15 @@ local lsp = require("lsp-zero")
|
|||
|
||||
vim.diagnostic.config { virtual_text = true }
|
||||
|
||||
lsp.preset({
|
||||
name = "recommended",
|
||||
set_lsp_keymaps = false,
|
||||
suggest_lsp_servers = true
|
||||
lsp.ensure_installed({
|
||||
'arduino_language_server', 'bashls', 'beancount', 'clangd', 'dockerls',
|
||||
'docker_compose_language_service', 'lua_ls', 'pyright', 'ruff_lsp', 'taplo',
|
||||
'yamlls'
|
||||
})
|
||||
lsp.preset({ name = "recommended", set_lsp_keymaps = false })
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
require("lsp-format").on_attach(client, bufnr)
|
||||
|
||||
local map = vim.keymap.set
|
||||
map('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>',
|
||||
{ buffer = bufnr, desc = 'Previous diagnostic' })
|
||||
|
@ -62,29 +64,136 @@ lsp.configure("pyright", {
|
|||
end
|
||||
})
|
||||
-- set up arduino with the help of arduino.nvim plugin
|
||||
lsp.configure("arduino_language_server",
|
||||
{ on_new_config = require('arduino').on_new_config })
|
||||
lsp.setup_nvim_cmp({
|
||||
sources = {
|
||||
{ name = 'path' }, { name = 'nvim_lsp', keyword_length = 2 },
|
||||
{ name = 'pandoc_references' }, { name = 'buffer', keyword_length = 3 },
|
||||
{ name = 'luasnip', keyword_length = 2 }, { name = 'tmux' },
|
||||
{ name = 'otter' }, { name = 'latex_symbols' }, { name = 'vCard' },
|
||||
{ name = 'nvim_lua' }, { name = 'buffer' }, { name = 'spell' }
|
||||
},
|
||||
documentation = {
|
||||
max_height = 50,
|
||||
max_width = 90,
|
||||
border = 'rounded',
|
||||
col_offset = 0,
|
||||
side_padding = 1,
|
||||
winhighlight = 'Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None',
|
||||
zindex = 1001
|
||||
}
|
||||
require('lspconfig').arduino_language_server.setup({
|
||||
on_new_config = require('arduino').on_new_config
|
||||
})
|
||||
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
||||
|
||||
lsp.setup()
|
||||
|
||||
|
||||
local luasnip = require("luasnip")
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "ﴯ",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "ﰠ",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = ""
|
||||
}
|
||||
local cmp = require 'cmp'
|
||||
cmp.setup({
|
||||
window = {
|
||||
documentation = cmp.config.window.bordered()
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'otter' },
|
||||
{ name = 'luasnip', keyword_length = 2 },
|
||||
{ name = 'pandoc_references' },
|
||||
{ name = 'nvim_lua' },
|
||||
{ name = 'beancount', option = {
|
||||
account = vim.env["HOME"] .. '/documents/records/budget/main.beancount' -- TODO implement dynamically
|
||||
} },
|
||||
{ name = 'calc' },
|
||||
{ name = 'path' },
|
||||
{ name = 'buffer', keyword_length = 3 },
|
||||
{ name = 'digraphs' },
|
||||
{ name = 'latex_symbols' },
|
||||
{ name = 'spell', keyword_length = 3 },
|
||||
{ name = 'tmux' },
|
||||
{ name = 'rg', keyword_length = 5 },
|
||||
{ name = 'vCard' },
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs( -4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
["<CR>"] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
if cmp.visible() and cmp.get_active_entry() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
s = cmp.mapping.confirm({ select = true }),
|
||||
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
||||
-- they way you will only jump inside the snippet region
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = 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" }),
|
||||
}),
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
-- Kind icons, removing kind text leaving only icon
|
||||
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
|
||||
vim_item.kind = string.format('%s', kind_icons[vim_item.kind])
|
||||
-- Source
|
||||
vim_item.menu = ({
|
||||
buffer = "[Buf]",
|
||||
calc = "[Cal]",
|
||||
digraphs = "[Dig]",
|
||||
latex_symbols = "[LaTeX]",
|
||||
luasnip = "[Snip]",
|
||||
nvim_lsp = "[Lsp]",
|
||||
nvim_lua = "[Lua]",
|
||||
pandoc_references = "[Bib]",
|
||||
spell = "[Spl]",
|
||||
vCard = "[vCrd]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end
|
||||
},
|
||||
})
|
||||
-- `/` cmdline setup.
|
||||
cmp.setup.cmdline('/', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
|
|
|
@ -194,22 +194,36 @@ return {
|
|||
"VonHeikemen/lsp-zero.nvim",
|
||||
dependencies = {
|
||||
{ "neovim/nvim-lspconfig", branch = "master" },
|
||||
"williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
branch = "main",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-buffer", "hrsh7th/cmp-path",
|
||||
"saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-nvim-lua", "andersevenrud/cmp-tmux",
|
||||
"hrsh7th/cmp-nvim-lsp", "kdheepak/cmp-latex-symbols",
|
||||
"ray-x/cmp-treesitter", "f3fora/cmp-spell",
|
||||
"hrsh7th/cmp-cmdline", "cbarrete/completion-vcard",
|
||||
"jc-doyle/cmp-pandoc-references"
|
||||
"andersevenrud/cmp-tmux",
|
||||
"cbarrete/completion-vcard",
|
||||
"f3fora/cmp-spell",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-calc",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"hrsh7th/cmp-nvim-lua",
|
||||
"dmitmel/cmp-digraphs",
|
||||
"jc-doyle/cmp-pandoc-references",
|
||||
"kdheepak/cmp-latex-symbols",
|
||||
"lukas-reineke/cmp-rg",
|
||||
"crispgm/cmp-beancount",
|
||||
"ray-x/cmp-treesitter",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
}
|
||||
}, "L3MON4D3/LuaSnip", "rafamadriz/friendly-snippets",
|
||||
},
|
||||
"L3MON4D3/LuaSnip",
|
||||
"rafamadriz/friendly-snippets",
|
||||
{ "lukas-reineke/lsp-format.nvim", config = true }
|
||||
},
|
||||
config = function() require('plug._lsp') end
|
||||
config = function() require('plug._lsp') end,
|
||||
branch = "v2.x"
|
||||
}, { 'simrat39/symbols-outline.nvim', config = true, event = "VeryLazy" }, -- vista-like outline view for code
|
||||
{ 'ray-x/lsp_signature.nvim', config = true }, -- UI improvements
|
||||
{ 'stevearc/dressing.nvim', config = true }, {
|
||||
|
|
Loading…
Reference in a new issue