From 6aa6efd1c90c5ed0725838a8b82097958cd05463 Mon Sep 17 00:00:00 2001 From: Ben Kyd Date: Tue, 10 Jun 2025 14:08:57 +0100 Subject: [PATCH] neovim bumps --- common/.config/nvim/lua/lsp-general.lua | 155 +++++++----------- .../nvim/lua/plugin-config/gitsigns.lua | 20 ++- .../lua/plugin-config/nvim-treesitter.lua | 23 ++- common/.config/nvim/lua/plugins.lua | 79 +++++---- common/.config/nvim/neovim.vim | 1 + 5 files changed, 140 insertions(+), 138 deletions(-) diff --git a/common/.config/nvim/lua/lsp-general.lua b/common/.config/nvim/lua/lsp-general.lua index 8cd154b..fcee30c 100644 --- a/common/.config/nvim/lua/lsp-general.lua +++ b/common/.config/nvim/lua/lsp-general.lua @@ -1,18 +1,9 @@ -local lsp = require('lsp-zero') +local lsp = require('lsp-zero'); local cmp = require('cmp') local luasnip = require('luasnip') local dap = require('dap') local dapui = require('dapui') -require('mason').setup({}) -require('mason-nvim-dap').setup({ - ensure_installed = { - 'cpptools', - 'cppdbg', - }, -}) -require('mason-lspconfig').setup({}) - dap.configurations = { cpp = { { @@ -107,52 +98,22 @@ end) vim.fn.sign_define('DapBreakpoint',{ text ='🔴', texthl ='', linehl ='', numhl =''}) vim.fn.sign_define('DapStopped',{ text ='▶️', texthl ='', linehl ='', numhl =''}) -lsp.preset({ - name = 'recommended', -}) - -lsp.ensure_installed({ - 'tsserver', - 'clangd', -}) - lsp.configure('clangd', { capabilities = { offsetEncoding = { "utf-16" } } }) -local cmp_mode = { behavior = cmp.SelectBehavior.Replace } -local cmp_mappings = lsp.defaults.cmp_mappings({ - [""] = cmp.mapping(function(fallback) - if (cmp.visible()) then - cmp.select_next_item(cmp_mode) - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - cmp.mapping.select_next_item(cmp_mode) - end, { 'i', 's' }), - [""] = cmp.mapping.select_prev_item(cmp_mode), -}) +-- lsp.setup_nvim_cmp({ +-- preselect = require('cmp').PreselectMode.None, +-- completion = { +-- completeopt = 'menu,menuone,noinsert,noselect' +-- }, +-- mapping = cmp_mappings, +-- }) --- unmap arrow keys -cmp_mappings[""] = nil -cmp_mappings[""] = nil - -lsp.setup_nvim_cmp({ - preselect = require('cmp').PreselectMode.None, - completion = { - completeopt = 'menu,menuone,noinsert,noselect' - }, - mapping = cmp_mappings, -}) - -lsp.on_attach(function(_, bufnr) - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - - local opts = { noremap = true, silent = true, buffer = bufnr } +lsp.on_attach(function(client, bufnr) + local opts = { buffer = bufnr } vim.keymap.set('n', 'gD', 'lua vim.lsp.buf.definition()', opts) vim.keymap.set('n', 'gT', 'lua vim.lsp.buf.type_definition()', opts) vim.keymap.set('n', 'gR', 'lua vim.lsp.buf.references()', opts) @@ -184,49 +145,9 @@ lsp.on_attach(function(_, bufnr) vim.keymap.set('n', 'gw', 'StripWhitespace', opts) end) -local rust_lsp = lsp.build_options('rust_analyzer', { - --cmd = { "/home/benk/programming/rust-analyzer/target/release/rust-analyzer" }, -}) - -require('rust-tools').setup({ - server = rust_lsp, - tools = { - inlay_hints = { - auto = true, - show_parameter_hints = true, - parameter_hints_prefix = " ", - other_hints_prefix = " ", - } - }, -}) lsp.setup() - -cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' } - } -}) - -cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) -}) - -lsp.set_preferences({ - suggest_lsp_servers = false, - sign_icons = { - error = '', - warn = '', - hint = '', - info = '' - } -}) - local cmp_kinds = { Text = "", Method = "", @@ -255,7 +176,21 @@ local cmp_kinds = { TypeParameter = "" } -local cmp_config = { + +require('mason').setup({}) +require('mason-lspconfig').setup({ + handlers = { + lsp.default_setup, + }, +}) + +cmp.setup({ + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'path' }, + }, window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered() @@ -295,11 +230,45 @@ local cmp_config = { performance = { max_view_entries = 20, }, -} + mapping = { + [""] = cmp.mapping(function(fallback) + if (cmp.visible()) then + cmp.select_next_item(cmp_mode) + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + cmp.mapping.select_next_item(cmp_mode) + end, { 'i', 's' }), + [""] = cmp.mapping.select_prev_item(cmp_mode), + [""] = nil, + [""] = nil + }, +}) -cmp.setup(cmp_config) +cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + } +}) + +cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) vim.api.nvim_set_hl(0, "CmpItemMenu", { italic = true }) vim.diagnostic.config({ - virtual_text = true + virtual_text = true, + signs = { + [vim.diagnostic.severity.ERROR] = '', + [vim.diagnostic.severity.WARN] = '', + [vim.diagnostic.severity.HINT] = '', + [vim.diagnostic.severity.INFO] = '' + } }) + diff --git a/common/.config/nvim/lua/plugin-config/gitsigns.lua b/common/.config/nvim/lua/plugin-config/gitsigns.lua index d1cba83..34d0094 100644 --- a/common/.config/nvim/lua/plugin-config/gitsigns.lua +++ b/common/.config/nvim/lua/plugin-config/gitsigns.lua @@ -1,10 +1,15 @@ require('gitsigns').setup { - keymaps = { - -- Default keymap options - noremap = true, - buffer = true, - ['n gb'] = 'lua require"gitsigns".blame_line()', - }, + on_attach = function(bufnr) + local gitsigns = require('gitsigns') + local function localmap(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + localmap('n', 'gb', gitsigns.toggle_current_line_blame) + end, + signs = { add = { text = '┃' }, change = { text = '┃' }, @@ -42,8 +47,5 @@ require('gitsigns').setup { row = 0, col = 1 }, - yadm = { - enable = false - }, } diff --git a/common/.config/nvim/lua/plugin-config/nvim-treesitter.lua b/common/.config/nvim/lua/plugin-config/nvim-treesitter.lua index 7b1ebfb..18b100b 100644 --- a/common/.config/nvim/lua/plugin-config/nvim-treesitter.lua +++ b/common/.config/nvim/lua/plugin-config/nvim-treesitter.lua @@ -1,8 +1,19 @@ require'nvim-treesitter.configs'.setup { - -- will install treesitter for all available languages - ensure_installed = 'all', - ignore_install = {'haskell'}, -- broken - highlight = { - enable = true - } + ensure_installed = { + "c", + "cpp", + "lua", + "python", + "javascript", + "typescript", + "html", + "css", + "bash", + "json", + "yaml", + "markdown", + }, + highlight = { + enable = true + } } diff --git a/common/.config/nvim/lua/plugins.lua b/common/.config/nvim/lua/plugins.lua index f3c8e0f..bf48e6a 100644 --- a/common/.config/nvim/lua/plugins.lua +++ b/common/.config/nvim/lua/plugins.lua @@ -5,6 +5,22 @@ return { priority = 1000, config = function() vim.cmd('colorscheme kanagawa') + require('kanagawa').setup({ + transparent = true, + undercurl = true, + commentStyle = { italic = true }, + keywordsStyle = { italic = true }, + statementStyle = { bold = true }, + overrides = function(colors) + return { + Normal = { bg = 'none' }, + NormalFloat = { bg = 'none' }, + FloatBorder = { fg = colors.palette.sumiInk4, bg = 'none' }, + CursorLine = { bg = colors.palette.sumiInk1 }, + CursorLineNr = { fg = colors.palette.sumiInk6, bold = true }, + } + end + }) end }, -- QUALITY OF LIFE INTEGRATIONS @@ -12,33 +28,40 @@ return { 'tpope/vim-fugitive', }, { - 'tzachar/local-highlight.nvim', - config = function() - require('local-highlight').setup({ - hlgroup = 'Search', - cw_hlgroup = nil, - -- Whether to display highlights in INSERT mode or not - insert_mode = true, - min_match_len = 1, - max_match_len = math.huge, - highlight_single_match = true, + 'hat0uma/csvview.nvim', + lazy = true, + }, + { + 'folke/snacks.nvim' + }, + { + 'tzachar/local-highlight.nvim', + config = function() + require('local-highlight').setup({ + hlgroup = 'Search', + cw_hlgroup = nil, + -- Whether to display highlights in INSERT mode or not + insert_mode = true, + min_match_len = 1, + max_match_len = math.huge, + highlight_single_match = true, }) - vim.api.nvim_create_autocmd('BufRead', { - pattern = {'*.*'}, - callback = function(data) - require('local-highlight').attach(data.buf) - end - }) - end - }, + vim.api.nvim_create_autocmd('BufRead', { + pattern = {'*.*'}, + callback = function(data) + require('local-highlight').attach(data.buf) + end + }) + end + }, { 'miversen33/sunglasses.nvim', config = function() require('sunglasses').setup({ - filter_type = "SHADE", - filter_percent = .20 + filter_type = "SHADE", + filter_percent = .20 }) - end + end }, { 'lewis6991/gitsigns.nvim', @@ -49,11 +72,11 @@ return { }, { -- Window picker - "yorickpeterse/nvim-window", - keys = { - { "e", "lua require('nvim-window').pick()", desc = "nvim-window: Jump to window" }, - }, - config = true, + "yorickpeterse/nvim-window", + keys = { + { "e", "lua require('nvim-window').pick()", desc = "nvim-window: Jump to window" }, + }, + config = true, }, { -- colourise colour codes @@ -265,14 +288,10 @@ return { }, { "L3MON4D3/LuaSnip", - -- follow latest release. - version = "v2.*", -- Replace by the latest released major (first number of latest release) - -- install jsregexp (optional!). build = "make install_jsregexp" }, { 'VonHeikemen/lsp-zero.nvim', - branch = 'v1.x', dependencies = { -- LSP Support { 'nvim-neotest/nvim-nio' }, diff --git a/common/.config/nvim/neovim.vim b/common/.config/nvim/neovim.vim index c023129..50a30cb 100644 --- a/common/.config/nvim/neovim.vim +++ b/common/.config/nvim/neovim.vim @@ -1,3 +1,4 @@ +"testg "augroup vimrc "autocmd! "autocmd BufWritePost plugins.lua PackerCompile