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 <leader>t and submap
- File manager moved to <leader>T
- Spell suggestion z= uses fzf
- LSP code actions <space>ca moved to <space>c and fzf
This commit is contained in:
2024-09-13 10:15:54 +02:00
parent 07ced57dc5
commit 73cb9eeca1
6 changed files with 62 additions and 36 deletions

View File

@@ -4,6 +4,7 @@
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp-rpncalc": { "branch": "master", "commit": "3d82861b41c54cb0b3c2c513563e1d8758c92625" },
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"fzf-lua": { "branch": "main", "commit": "f39de2d77755e90a7a80989b007f0bf2ca13b0dd" }, "fzf-lua": { "branch": "main", "commit": "f39de2d77755e90a7a80989b007f0bf2ca13b0dd" },
"lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" }, "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" },
@@ -20,6 +21,7 @@
"nvim-web-devicons": { "branch": "master", "commit": "9793801f974bba70e4ac5d7eae6c4f5659993d8e" }, "nvim-web-devicons": { "branch": "master", "commit": "9793801f974bba70e4ac5d7eae6c4f5659993d8e" },
"orgmode": { "branch": "master", "commit": "e3500add486b17da58ce8e42a0f799161e5761c9" }, "orgmode": { "branch": "master", "commit": "e3500add486b17da58ce8e42a0f799161e5761c9" },
"plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" },
"vim-table-mode": { "branch": "master", "commit": "e4365bde024f73e205eefa2fb78e3029ddb92ea9" },
"which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" }, "which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" },
"workspaces.nvim": { "branch": "master", "commit": "0b03d3f2ffe38729b1792905ec447405ed76cb6e" } "workspaces.nvim": { "branch": "master", "commit": "0b03d3f2ffe38729b1792905ec447405ed76cb6e" }
} }

View File

@@ -16,7 +16,7 @@ cmp.setup({
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
-- Use <C-b/f> to scroll the docs -- Use <C-b/f> to scroll the docs
['<C-b>'] = cmp.mapping.scroll_docs( -4), ['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
-- Use <C-k/j> to switch in items -- Use <C-k/j> to switch in items
['<C-k>'] = cmp.mapping.select_prev_item(), ['<C-k>'] = cmp.mapping.select_prev_item(),
@@ -40,40 +40,41 @@ cmp.setup({
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable( -1) then elseif luasnip.jumpable(-1) then
luasnip.jump( -1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
}), }),
-- Let's configure the item's appearance -- Let's configure the item's appearance
-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance -- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance
formatting = { formatting = {
-- Set order from left to right -- Set order from left to right
-- kind: single letter indicating the type of completion -- kind: single letter indicating the type of completion
-- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word" -- 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" -- menu: extra text for the popup menu, displayed after "word" or "abbr"
fields = { 'abbr', 'menu' }, fields = { 'abbr', 'menu' },
-- customize the appearance of the completion menu -- customize the appearance of the completion menu
format = function(entry, vim_item) format = function(entry, vim_item)
vim_item.menu = ({ vim_item.menu = ({
nvim_lsp = '[Lsp]', nvim_lsp = '[Lsp]',
luasnip = '[Luasnip]', luasnip = '[Luasnip]',
buffer = '[File]', buffer = '[File]',
path = '[Path]', path = '[Path]',
})[entry.source.name] })[entry.source.name]
return vim_item return vim_item
end, end,
}, },
-- Set source precedence -- Set source precedence
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- For nvim-lsp { name = 'nvim_lsp' }, -- For nvim-lsp
{ name = 'luasnip' }, -- For luasnip user { name = 'luasnip' }, -- For luasnip user
{ name = 'buffer' }, -- For buffer word completion { name = 'buffer' }, -- For buffer word completion
{ name = 'path' }, -- For path completion { name = 'path' }, -- For path completion
}) { name = 'rpncalc' }, -- for RPN calculations
})
}) })

View File

@@ -11,10 +11,11 @@ vim.keymap.set('n', '<leader>b', fzf.buffers, { desc = "Buffers" })
-- use fzf buffer lines as default search -- use fzf buffer lines as default search
vim.keymap.set('n', '/', fzf.blines, { desc = "Search buffer" }) 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 -- open file manager and git
vim.keymap.set('n', '<leader>g', ":Neogit<CR>", { desc = "Git Manager" }) vim.keymap.set('n', '<leader>g', ":Neogit<CR>", { desc = "Git Manager" })
vim.keymap.set('n', '<leader>t', ":Neotree<CR>", { desc = "File Manager" }) vim.keymap.set('n', '<leader>T', ":Neotree<CR>", { desc = "File Manager" })
-- --
-- configure workspaces -- configure workspaces
@@ -40,4 +41,4 @@ workspaces_fzf_picker = function(opts)
fzf_cb() -- EOF fzf_cb() -- EOF
end, opts) end, opts)
end end
vim.keymap.set('n', '<leader>w', workspaces_fzf_picker) vim.keymap.set('n', '<leader>w', workspaces_fzf_picker, { desc = "Workspaces" } )

View File

@@ -17,6 +17,7 @@ require('mason-lspconfig').setup({
'yamlls', 'yamlls',
'tsserver', 'tsserver',
'gopls', 'gopls',
'pylsp',
-- 'volar', -- 'volar',
}, },
}) })
@@ -25,9 +26,9 @@ require('mason-lspconfig').setup({
-- See `:help vim.diagnostic.*` for documentation on any of the below functions -- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap = true, silent = true } local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts) vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, 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', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys -- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
@@ -49,7 +50,7 @@ local on_attach = function(client, bufnr)
end, bufopts) end, bufopts)
-- vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts) -- vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts) -- vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set("n", "<space>f", function() vim.keymap.set("n", "<space>f", function()
vim.lsp.buf.format({ async = true }) vim.lsp.buf.format({ async = true })
end, bufopts) end, bufopts)
@@ -60,6 +61,7 @@ local on_attach = function(client, bufnr)
vim.keymap.set('n', '<space>d', fzf.diagnostics_document , { desc = "Doc diagnostics" }) vim.keymap.set('n', '<space>d', fzf.diagnostics_document , { desc = "Doc diagnostics" })
vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" }) vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" })
vim.keymap.set('n', '<space>s', fzf.lsp_document_symbols, { desc = "Doc symbols" }) vim.keymap.set('n', '<space>s', fzf.lsp_document_symbols, { desc = "Doc symbols" })
vim.keymap.set('n', '<space>c', fzf.lsp_code_actions, { desc = "Code Actions" })
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<C-[>', fzf.lsp_references, { desc = "Find References" }) vim.keymap.set('n', '<C-[>', fzf.lsp_references, { desc = "Find References" })
vim.keymap.set('n', '<C-]>', fzf.lsp_definitions, { desc = "Find References" }) vim.keymap.set('n', '<C-]>', fzf.lsp_definitions, { desc = "Find References" })

View File

@@ -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 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 -- Wrapping movements and long lines
vim.opt.whichwrap = "b,s,<,>,[,]" -- wrap backspace, space and left-right cursor keys vim.opt.whichwrap = "b,s,<,>,[,]" -- wrap backspace, space and left-right cursor keys
vim.opt.wrap = false vim.opt.wrap = false
-- formatoptions not very well set
-- vim.opt.formatoptions = "tac" vim.opt.spell = true
vim.opt.spelllang = "de,en"

View File

@@ -124,7 +124,7 @@ require("lazy").setup({
local configs = require("nvim-treesitter.configs") local configs = require("nvim-treesitter.configs")
configs.setup({ 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, sync_install = false,
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
@@ -198,6 +198,12 @@ require("lazy").setup({
"natecraddock/workspaces.nvim", "natecraddock/workspaces.nvim",
config = function() config = function()
require("workspaces").setup { 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 -- option to automatically activate workspace when opening neovim in a workspace directory
auto_open = true, auto_open = true,
@@ -211,4 +217,12 @@ require("lazy").setup({
end end
}, },
-- rpn calculator
-- also added as source to cmp
{
"PhilRunninger/cmp-rpncalc",
},
-- comfortable table editing
{ 'dhruvasagar/vim-table-mode' },
}) })