From 6b28e6417b5cbb7436b6c2641ca4fbc0fda180fe Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 22 Mar 2023 08:30:04 +0100 Subject: [PATCH 1/6] 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. --- nvim/.config/nvim/lazy-lock.json | 12 ++- nvim/.config/nvim/lua/plug/_lsp.lua | 155 +++++++++++++++++++++++----- nvim/.config/nvim/lua/plugins.lua | 42 +++++--- 3 files changed, 168 insertions(+), 41 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 910c50a..890cfbb 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -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" }, diff --git a/nvim/.config/nvim/lua/plug/_lsp.lua b/nvim/.config/nvim/lua/plug/_lsp.lua index 62ea75f..5e22b4e 100644 --- a/nvim/.config/nvim/lua/plug/_lsp.lua +++ b/nvim/.config/nvim/lua/plug/_lsp.lua @@ -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', 'lua vim.diagnostic.goto_prev()', { 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({ + [''] = cmp.mapping.scroll_docs( -4), + [''] = cmp.mapping.scroll_docs(4), + [""] = 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 }), + }), + [""] = 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" }), + [""] = 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(), diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 14b7dac..43c4aa0 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -194,22 +194,36 @@ return { "VonHeikemen/lsp-zero.nvim", dependencies = { { "neovim/nvim-lspconfig", branch = "master" }, - "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" - } - }, "L3MON4D3/LuaSnip", "rafamadriz/friendly-snippets", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + { + "hrsh7th/nvim-cmp", + branch = "main", + dependencies = { + "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", { "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 }, { From d1b0dfe11248a4f0c3188f3efd1f779cb8ae872c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 22 Mar 2023 10:21:52 +0100 Subject: [PATCH 2/6] nvim: Improve diagnostics gutter rendering --- nvim/.config/nvim/lua/plug/_lsp.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nvim/.config/nvim/lua/plug/_lsp.lua b/nvim/.config/nvim/lua/plug/_lsp.lua index 5e22b4e..496ff80 100644 --- a/nvim/.config/nvim/lua/plug/_lsp.lua +++ b/nvim/.config/nvim/lua/plug/_lsp.lua @@ -1,6 +1,10 @@ local lsp = require("lsp-zero") vim.diagnostic.config { virtual_text = true } +vim.fn.sign_define("DiagnosticSignError", { text = "✘", texthl = "DiagnosticSignError" }) +vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn" }) +vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" }) +vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) lsp.ensure_installed({ 'arduino_language_server', 'bashls', 'beancount', 'clangd', 'dockerls', From ce9f101024db06361c1b721c80fd34ef2e534d01 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 22 Mar 2023 10:22:34 +0100 Subject: [PATCH 3/6] nvim: Unify lsp mappings into local +l prefix Whereas previously we had lsp-related mappings both on l... and g... mappings, they are now all unified under the l prefix group. Some mnemonics unfortunately had to give way to a weaker version of themselves (definition becomes de[f]inition, implementation becomes i[m]plementation) but overall I believe this to be much more cohesive for my future lsp usage. With which-key enabled and everything under the +l group we should be able to easily adapt to the new mappings. Additionally, some mappings will invoke the telescope version of their lsp command if telescope is indeed installed, otherwise fall back to the native neovim lsp implementation. --- nvim/.config/nvim/lua/plug/_lsp.lua | 33 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/nvim/.config/nvim/lua/plug/_lsp.lua b/nvim/.config/nvim/lua/plug/_lsp.lua index 496ff80..6ac022f 100644 --- a/nvim/.config/nvim/lua/plug/_lsp.lua +++ b/nvim/.config/nvim/lua/plug/_lsp.lua @@ -37,8 +37,25 @@ lsp.on_attach(function(client, bufnr) { buffer = bufnr, desc = 'Codeactions' }) map('n', 'ln', 'lua vim.lsp.buf.rename()', { buffer = bufnr, desc = 'Rename element' }) - map('n', 'lr', 'lua vim.lsp.buf.references()', - { buffer = bufnr, desc = 'References' }) + if vim.fn.exists(':Telescope') then + map('n', 'lr', 'Telescope lsp_references()', + { buffer = bufnr, desc = 'References' }) + map('n', 'lf', 'Telescope lsp_definitions', + { buffer = bufnr, desc = 'Definition' }) + map('n', 'lt', 'Telescope lsp_type_definitions', + { buffer = bufnr, desc = 'Type definition' }) + map('n', 'lm', 'Telescope lsp_implementations', + { buffer = bufnr, desc = 'Implementation' }) + else + map('n', 'lr', 'lua vim.lsp.buf.references()', + { buffer = bufnr, desc = 'References' }) + map('n', 'lf', 'lua vim.lsp.buf.definition()', + { buffer = bufnr, desc = 'Definition' }) + map('n', 'lt', 'lua vim.lsp.buf.type_definition()', + { buffer = bufnr, desc = 'Type definition' }) + map('n', 'lm', 'lua vim.lsp.buf.implementation()', + { buffer = bufnr, desc = 'Implementation' }) + end if client.server_capabilities.document_formatting then map('n', 'lf', "lua vim.lsp.buf.formatting()", { buffer = bufnr, desc = 'Format document' }) @@ -46,23 +63,17 @@ lsp.on_attach(function(client, bufnr) map('n', 'K', 'lua vim.lsp.buf.hover()', { buffer = bufnr, desc = 'Hover definition' }) - map('n', 'gd', 'lua vim.lsp.buf.definition()', - { buffer = bufnr, desc = 'Definition' }) - map('n', 'gD', 'lua vim.lsp.buf.declaration()', + map('n', 'lc', 'lua vim.lsp.buf.declaration()', { buffer = bufnr, desc = 'Declaration' }) - map('n', 'gs', 'lua vim.lsp.buf.signature_help()', + map('n', 'ls', 'lua vim.lsp.buf.signature_help()', { buffer = bufnr, desc = 'Signature help' }) - map('n', 'gI', 'lua vim.lsp.buf.implementation()', - { buffer = bufnr, desc = 'Implementation' }) - map('n', 'gt', 'lua vim.lsp.buf.type_definition()', - { buffer = bufnr, desc = 'Type definition' }) end) lsp.nvim_workspace() -- ensure python virtualenv is determined automatically on lsp start lsp.configure("pyright", { on_attach = function(client, _) local python_path, msg = require('util.pyenv').get_path(client.config - .root_dir) + .root_dir) vim.notify(string.format('%s\n%s', msg, python_path)) client.config.settings.python.pythonPath = python_path end From 643d282bac402fe83eab17d7e3847313463e5860 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 22 Mar 2023 10:26:06 +0100 Subject: [PATCH 4/6] nvim: Improve cmdline completion When completing in command line I want the completion canditates to be displayed, but *not* selected on confirmation. By doing so, it makes it almost impossible to quickly quit with ':q' or write with ':w' for example, as those always try to expand themselves automatically into completion items. This commit changes the default behavior for command mode to show completions but not auto accept any on confirmation, instead simply invoking whatever is currently on the command line (as if we had no completion plugin running). --- nvim/.config/nvim/lua/plug/_lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plug/_lsp.lua b/nvim/.config/nvim/lua/plug/_lsp.lua index 6ac022f..ce866a8 100644 --- a/nvim/.config/nvim/lua/plug/_lsp.lua +++ b/nvim/.config/nvim/lua/plug/_lsp.lua @@ -161,7 +161,7 @@ cmp.setup({ end end, s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }), -- disable selection in cmd mode }), [""] = cmp.mapping(function(fallback) if cmp.visible() then From 22cfa037df71f9d188b0b457110b25e4c71a7b20 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 22 Mar 2023 10:32:11 +0100 Subject: [PATCH 5/6] nvim: Add fidget.nvim Added fidget plugin which shows the current loading status of LSPs. Only works for a few LSP (so far), including lua and python. Should automatically pick up new implementations on update. Will display a small loading notification in the lower right corner, useful to display status for those situations where LSP loading takes a long time (e.g. rust compilation requirements or a large python environment). FIXME Does not work for each python environment startup yet, and I am not sure why - sometimes just does not display its loading startup. --- nvim/.config/nvim/lazy-lock.json | 1 + nvim/.config/nvim/lua/plugins.lua | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 890cfbb..423307a 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -23,6 +23,7 @@ "dial.nvim": { "branch": "master", "commit": "54b503f906bc9e5ab85288414840a1b86d40769f" }, "dressing.nvim": { "branch": "master", "commit": "5f44f829481640be0f96759c965ae22a3bcaf7ce" }, "easyread.nvim": { "branch": "main", "commit": "73df5f4dc8fd38bef079b890b2a34412844c00b1" }, + "fidget.nvim": { "branch": "main", "commit": "688b4fec4517650e29c3e63cfbb6e498b3112ba1" }, "formatter.nvim": { "branch": "master", "commit": "ed949c13e1a942db29ababa35e8c7864ced90eb6" }, "friendly-snippets": { "branch": "main", "commit": "25ddcd96540a2ce41d714bd7fea2e7f75fea8ead" }, "fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" }, diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 43c4aa0..e3c96bc 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -220,7 +220,8 @@ return { }, "L3MON4D3/LuaSnip", "rafamadriz/friendly-snippets", - { "lukas-reineke/lsp-format.nvim", config = true } + { "lukas-reineke/lsp-format.nvim", config = true }, + { "j-hui/fidget.nvim", config = true } -- loading animations for some LSP }, config = function() require('plug._lsp') end, branch = "v2.x" From 36d411dafa7306bfa6847905570529f34b83caca Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 22 Mar 2023 10:35:00 +0100 Subject: [PATCH 6/6] nvim: Format files --- nvim/.config/nvim/lua/plug/_lsp.lua | 37 ++++++++++-------- nvim/.config/nvim/lua/plugins.lua | 60 ++++++++++++++++------------- 2 files changed, 53 insertions(+), 44 deletions(-) diff --git a/nvim/.config/nvim/lua/plug/_lsp.lua b/nvim/.config/nvim/lua/plug/_lsp.lua index ce866a8..ee86304 100644 --- a/nvim/.config/nvim/lua/plug/_lsp.lua +++ b/nvim/.config/nvim/lua/plug/_lsp.lua @@ -136,9 +136,12 @@ cmp.setup({ { 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 = 'beancount', + option = { + account = vim.env["HOME"] .. '/documents/records/budget/main.beancount' -- TODO implement dynamically + } + }, { name = 'calc' }, { name = 'path' }, { name = 'buffer', keyword_length = 3 }, @@ -150,7 +153,7 @@ cmp.setup({ { name = 'vCard' }, }, mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs( -4), + [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping({ i = function(fallback) @@ -179,8 +182,8 @@ cmp.setup({ [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable( -1) then - luasnip.jump( -1) + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) else fallback() end @@ -194,17 +197,17 @@ cmp.setup({ 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] + 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 }, diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index e3c96bc..d833ab9 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -4,13 +4,13 @@ return { -- vim plugs -- essential { 'numToStr/Navigator.nvim', branch = "master", config = true }, -- allow seamless navigation between vim buffers and tmux/wezterm splits - { 'jeffkreeftmeijer/vim-numbertoggle', event = "BufEnter" }, -- toggles numbers to absolute for all buffers but the current which is relative - { 'ojroques/vim-oscyank', event = "VeryLazy" }, -- yank from *anywhere* (even ssh session) to clipboard, using :OSCYank - { 'ggandor/lightspeed.nvim', event = "VeryLazy" }, -- jump between letters with improved fFtT quicksearch, mimics sneak + { 'jeffkreeftmeijer/vim-numbertoggle', event = "BufEnter" }, -- toggles numbers to absolute for all buffers but the current which is relative + { 'ojroques/vim-oscyank', event = "VeryLazy" }, -- yank from *anywhere* (even ssh session) to clipboard, using :OSCYank + { 'ggandor/lightspeed.nvim', event = "VeryLazy" }, -- jump between letters with improved fFtT quicksearch, mimics sneak -- files - { 'vifm/vifm.vim' }, -- integrate file manager + { 'vifm/vifm.vim' }, -- integrate file manager { - 'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter + 'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter opts = { numhl = true, signcolumn = false }, event = "BufRead" }, { @@ -25,10 +25,10 @@ return { 'mhartington/formatter.nvim', -- auto formatting on save config = function() require('plug._format') end, event = "VeryLazy" -}, -- editing +}, -- editing { 'kylechui/nvim-surround', version = '*', config = true, event = "VeryLazy" }, -- surround things with other things using ys/cs/ds { - 'monaqa/dial.nvim', -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers + 'monaqa/dial.nvim', -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers config = function() local augend = require("dial.augend") require("dial.config").augends:register_group { @@ -44,15 +44,15 @@ return { augend.constant.alias.Alpha, augend.constant.alias.alpha, augend.hexcolor.new { case = "lower" }, augend.constant.new { elements = { "and", "or" }, - word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. + word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. cyclic = true -- "or" is incremented into "and". }, augend.constant - .new { - elements = { "&&", "||" }, - word = false, - cyclic = true - } + .new { + elements = { "&&", "||" }, + word = false, + cyclic = true + } } } end, @@ -61,7 +61,7 @@ return { 'tommcdo/vim-exchange', -- adds exchange operator with cx. common use: cxiw . on 2 words to switch event = "VeryLazy" }, { - 'junegunn/vim-easy-align', -- Align tables and other alignable things + 'junegunn/vim-easy-align', -- Align tables and other alignable things event = "VeryLazy" }, { 'edKotinsky/Arduino.nvim', ft = 'arduino', config = true }, -- statusline { @@ -69,7 +69,7 @@ return { requires = { 'kyazdani42/nvim-web-devicons', opt = true }, config = function() require('plug._lualine') end }, -- writing - { 'vim-pandoc/vim-criticmarkup', ft = writing_ft }, { + { 'vim-pandoc/vim-criticmarkup', ft = writing_ft }, { 'mickael-menu/zk-nvim', config = function() require('zk').setup({ picker = "telescope" }) end }, { @@ -84,7 +84,8 @@ return { 'quarto-dev/quarto-nvim', dependencies = { 'jmbuhr/otter.nvim', 'neovim/nvim-lspconfig', - 'vim-pandoc/vim-pandoc-syntax' + 'vim-pandoc/vim-pandoc-syntax', 'hrsh7th/nvim-cmp', + 'nvim-treesitter/nvim-treesitter' }, config = function() require 'quarto'.setup { @@ -109,18 +110,23 @@ return { desc = "Inspect object in kernel" } } -}, { 'micarmst/vim-spellsync', event = "VeryLazy" }, -- personal dict improvements for git sync - { 'folke/zen-mode.nvim', config = true, event = "VeryLazy" }, -- provide distraction free writing - { 'folke/twilight.nvim', event = "VeryLazy" }, -- provide even distraction free-er writing (lowlight paragraphs) - { 'JellyApple102/easyread.nvim', config = true, ft = writing_ft, cmd = 'EasyreadToggle' }, -- enable 'speed-reading' mode (bionic reading) - { 'marty-oehme/zettelkasten.nvim', ft = writing_ft, event = "VeryLazy" }, -- simple static markdown linking +}, { 'micarmst/vim-spellsync', event = "VeryLazy" }, -- personal dict improvements for git sync + { 'folke/zen-mode.nvim', config = true, event = "VeryLazy" }, -- provide distraction free writing + { 'folke/twilight.nvim', event = "VeryLazy" }, -- provide even distraction free-er writing (lowlight paragraphs) { - "iamcco/markdown-preview.nvim", -- generate an auto-updating html preview for md files + 'JellyApple102/easyread.nvim', + config = true, + ft = writing_ft, + cmd = 'EasyreadToggle' + }, -- enable 'speed-reading' mode (bionic reading) + { 'marty-oehme/zettelkasten.nvim', ft = writing_ft, event = "VeryLazy" }, -- simple static markdown linking + { + "iamcco/markdown-preview.nvim", -- generate an auto-updating html preview for md files build = function() vim.fn["mkdp#util#install"]() end, ft = writing_ft - }, -- languages - { 'euclidianAce/BetterLua.vim', ft = 'lua' }, -- better syntax highlighting for lua - { 'aliou/bats.vim', ft = { "bash", "sh", "zsh", "bats" } }, -- enable syntax for bats shell-code testing library + }, -- languages + { 'euclidianAce/BetterLua.vim', ft = 'lua' }, -- better syntax highlighting for lua + { 'aliou/bats.vim', ft = { "bash", "sh", "zsh", "bats" } }, -- enable syntax for bats shell-code testing library -- REPL work { @@ -172,7 +178,7 @@ return { }, { 'nvim-treesitter/playground', cmd = "TSPlaygroundToggle" }, -- interactively view and query the treesitter tree { - 'RRethy/nvim-treesitter-textsubjects', -- allows using . and ; to target treesitter branches + 'RRethy/nvim-treesitter-textsubjects', -- allows using . and ; to target treesitter branches config = function() require 'nvim-treesitter.configs'.setup { textsubjects = { @@ -226,7 +232,7 @@ return { 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 + { 'ray-x/lsp_signature.nvim', config = true }, -- UI improvements { 'stevearc/dressing.nvim', config = true }, { 'rcarriga/nvim-notify', config = function() vim.notify = require("notify") end