From 73cb9eeca126abf53c9d2932bc0dfacf17d06326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20L=C3=BCdecke?= Date: Fri, 13 Sep 2024 10:15:54 +0200 Subject: [PATCH] Table mode, RPN calc, Python LSP and key bindings Options and plugins: - enabled spell checker with languages de and en - RPN calculator added to cmp - Added python to lsps - fzf workspaces now always sorted by name Key bindings: - table mode added, use t and submap - File manager moved to T - Spell suggestion z= uses fzf - LSP code actions ca moved to c and fzf --- lazy-lock.json | 2 ++ lua/config/nvim-cmp.lua | 59 +++++++++++++++++++++-------------------- lua/keybindings.lua | 5 ++-- lua/lsp.lua | 6 +++-- lua/options.lua | 10 +++++-- lua/plugins.lua | 16 ++++++++++- 6 files changed, 62 insertions(+), 36 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 5eda8b7..545f301 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -4,6 +4,7 @@ "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-rpncalc": { "branch": "master", "commit": "3d82861b41c54cb0b3c2c513563e1d8758c92625" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "fzf-lua": { "branch": "main", "commit": "f39de2d77755e90a7a80989b007f0bf2ca13b0dd" }, "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" }, @@ -20,6 +21,7 @@ "nvim-web-devicons": { "branch": "master", "commit": "9793801f974bba70e4ac5d7eae6c4f5659993d8e" }, "orgmode": { "branch": "master", "commit": "e3500add486b17da58ce8e42a0f799161e5761c9" }, "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, + "vim-table-mode": { "branch": "master", "commit": "e4365bde024f73e205eefa2fb78e3029ddb92ea9" }, "which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" }, "workspaces.nvim": { "branch": "master", "commit": "0b03d3f2ffe38729b1792905ec447405ed76cb6e" } } diff --git a/lua/config/nvim-cmp.lua b/lua/config/nvim-cmp.lua index 6ecd795..5f4421f 100644 --- a/lua/config/nvim-cmp.lua +++ b/lua/config/nvim-cmp.lua @@ -16,7 +16,7 @@ cmp.setup({ }, mapping = cmp.mapping.preset.insert({ -- Use to scroll the docs - [''] = cmp.mapping.scroll_docs( -4), + [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), -- Use to switch in items [''] = cmp.mapping.select_prev_item(), @@ -40,40 +40,41 @@ 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 end, { "i", "s" }), }), - -- Let's configure the item's appearance - -- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance - formatting = { - -- Set order from left to right - -- kind: single letter indicating the type of completion - -- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word" - -- menu: extra text for the popup menu, displayed after "word" or "abbr" - fields = { 'abbr', 'menu' }, + -- Let's configure the item's appearance + -- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance + formatting = { + -- Set order from left to right + -- kind: single letter indicating the type of completion + -- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word" + -- menu: extra text for the popup menu, displayed after "word" or "abbr" + fields = { 'abbr', 'menu' }, - -- customize the appearance of the completion menu - format = function(entry, vim_item) - vim_item.menu = ({ - nvim_lsp = '[Lsp]', - luasnip = '[Luasnip]', - buffer = '[File]', - path = '[Path]', - })[entry.source.name] - return vim_item - end, - }, + -- customize the appearance of the completion menu + format = function(entry, vim_item) + vim_item.menu = ({ + nvim_lsp = '[Lsp]', + luasnip = '[Luasnip]', + buffer = '[File]', + path = '[Path]', + })[entry.source.name] + return vim_item + end, + }, - -- Set source precedence - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, -- For nvim-lsp - { name = 'luasnip' }, -- For luasnip user - { name = 'buffer' }, -- For buffer word completion - { name = 'path' }, -- For path completion - }) + -- Set source precedence + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, -- For nvim-lsp + { name = 'luasnip' }, -- For luasnip user + { name = 'buffer' }, -- For buffer word completion + { name = 'path' }, -- For path completion + { name = 'rpncalc' }, -- for RPN calculations + }) }) diff --git a/lua/keybindings.lua b/lua/keybindings.lua index 485aff1..3a93536 100644 --- a/lua/keybindings.lua +++ b/lua/keybindings.lua @@ -11,10 +11,11 @@ vim.keymap.set('n', 'b', fzf.buffers, { desc = "Buffers" }) -- use fzf buffer lines as default search vim.keymap.set('n', '/', fzf.blines, { desc = "Search buffer" }) +vim.keymap.set('n', 'z=', fzf.spell_suggest, { desc = "Spelling suggestions" }) -- open file manager and git vim.keymap.set('n', 'g', ":Neogit", { desc = "Git Manager" }) -vim.keymap.set('n', 't', ":Neotree", { desc = "File Manager" }) +vim.keymap.set('n', 'T', ":Neotree", { desc = "File Manager" }) -- -- configure workspaces @@ -40,4 +41,4 @@ workspaces_fzf_picker = function(opts) fzf_cb() -- EOF end, opts) end -vim.keymap.set('n', 'w', workspaces_fzf_picker) +vim.keymap.set('n', 'w', workspaces_fzf_picker, { desc = "Workspaces" } ) diff --git a/lua/lsp.lua b/lua/lsp.lua index 601488b..b0e75fa 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -17,6 +17,7 @@ require('mason-lspconfig').setup({ 'yamlls', 'tsserver', 'gopls', + 'pylsp', -- 'volar', }, }) @@ -25,9 +26,9 @@ require('mason-lspconfig').setup({ -- See `:help vim.diagnostic.*` for documentation on any of the below functions local opts = { noremap = true, silent = true } vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer @@ -49,7 +50,7 @@ local on_attach = function(client, bufnr) end, bufopts) -- vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + -- vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) vim.keymap.set("n", "f", function() vim.lsp.buf.format({ async = true }) end, bufopts) @@ -60,6 +61,7 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', 'd', fzf.diagnostics_document , { desc = "Doc diagnostics" }) vim.keymap.set('n', 'D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" }) vim.keymap.set('n', 's', fzf.lsp_document_symbols, { desc = "Doc symbols" }) + vim.keymap.set('n', 'c', fzf.lsp_code_actions, { desc = "Code Actions" }) -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) vim.keymap.set('n', '', fzf.lsp_references, { desc = "Find References" }) vim.keymap.set('n', '', fzf.lsp_definitions, { desc = "Find References" }) diff --git a/lua/options.lua b/lua/options.lua index 06bee03..7f2ea20 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -25,8 +25,14 @@ vim.opt.ignorecase = true -- ignore case in searches by default vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered +-------------------------------------------------- +-- +-- General text editing and cursor movements +-- +-------------------------------------------------- -- Wrapping movements and long lines vim.opt.whichwrap = "b,s,<,>,[,]" -- wrap backspace, space and left-right cursor keys vim.opt.wrap = false --- formatoptions not very well set --- vim.opt.formatoptions = "tac" + +vim.opt.spell = true +vim.opt.spelllang = "de,en" diff --git a/lua/plugins.lua b/lua/plugins.lua index 098bf01..91c1f74 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -124,7 +124,7 @@ require("lazy").setup({ local configs = require("nvim-treesitter.configs") configs.setup({ - ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html", "diff", "go", "rust" }, + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html", "diff", "go", "rust", "python" }, sync_install = false, highlight = { enable = true }, indent = { enable = true }, @@ -198,6 +198,12 @@ require("lazy").setup({ "natecraddock/workspaces.nvim", config = function() require("workspaces").setup { + -- sort the list of workspaces by name after loading from the workspaces path. + sort = true, + + -- sort by recent use rather than by name. requires sort to be true + mru_sort = false, + -- option to automatically activate workspace when opening neovim in a workspace directory auto_open = true, @@ -211,4 +217,12 @@ require("lazy").setup({ end }, + -- rpn calculator + -- also added as source to cmp + { + "PhilRunninger/cmp-rpncalc", + }, + + -- comfortable table editing + { 'dhruvasagar/vim-table-mode' }, })