From bcf4e0f9547a4fc1a4e4e03e3cb1c4314f750daa Mon Sep 17 00:00:00 2001 From: Xander Swan Date: Wed, 3 Dec 2025 10:00:41 -0500 Subject: nvim --- .config/nvim/lua/plugin/lsp.lua | 21 +++++++++++++-------- .config/nvim/lua/plugin/packer.lua | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) (limited to '.config/nvim/lua/plugin') diff --git a/.config/nvim/lua/plugin/lsp.lua b/.config/nvim/lua/plugin/lsp.lua index 8e9d66f..0c02c4f 100644 --- a/.config/nvim/lua/plugin/lsp.lua +++ b/.config/nvim/lua/plugin/lsp.lua @@ -23,22 +23,27 @@ local cmp = require('cmp') cmp.setup { mapping = cmp.mapping.preset.insert({ -- `Enter` key to confirm completion - [''] = cmp.mapping.confirm({select = false}), + [''] = cmp.mapping.confirm({ select = false }), -- `Tab` key to navigate - [''] = cmp.mapping.select_prev_item({behavior = 'select'}), - [''] = cmp.mapping.select_next_item({behavior = 'select'}), + [''] = cmp.mapping.select_prev_item({ behavior = 'select' }), + [''] = cmp.mapping.select_next_item({ behavior = 'select' }), }) } +require("lsp-format").setup {} +require("lspconfig").clangd.setup { + on_attach = require("lsp-format").on_attach +} + lsp.on_attach(function(client, buffer) - local opts = { buffer=buffer, remap=false } + local opts = { buffer = buffer, remap = false } - vim.keymap.set("n", "ld", function() vim.lsp.buf.definition() end, opts) - vim.keymap.set("n", "h", function() vim.lsp.buf.hover() end, opts) - vim.keymap.set("n", "la", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "ld", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "h", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "la", function() vim.lsp.buf.code_action() end, opts) vim.keymap.set("n", "lrf", function() vim.lsp.buf.references() end, opts) vim.keymap.set("n", "lrn", function() vim.lsp.buf.rename() end, opts) - vim.keymap.set("n", "ls", function() vim.lsp.buf.signature_help() end, opts) + vim.keymap.set("n", "ls", function() vim.lsp.buf.signature_help() end, opts) end) lsp.setup() diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index 653b786..f03cca2 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -34,6 +34,7 @@ return require("packer").startup(function(use) use { "VonHeikemen/lsp-zero.nvim", requires = { + {"lukas-reineke/lsp-format.nvim"}, -- LSP Support {"neovim/nvim-lspconfig"}, {"williamboman/mason.nvim"}, -- cgit v1.3-2-g0d8e