From 6c14c49c4a00817c2a575be4318030e4df1d9458 Mon Sep 17 00:00:00 2001 From: Charles Danesi Date: Mon, 25 Nov 2024 09:17:02 -0500 Subject: [PATCH] add BufWritePost event --- .config/nvim/lua/plugins/lsp/lspconfig.lua | 222 ++++++++++----------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/.config/nvim/lua/plugins/lsp/lspconfig.lua b/.config/nvim/lua/plugins/lsp/lspconfig.lua index b79f29c..052dcbb 100644 --- a/.config/nvim/lua/plugins/lsp/lspconfig.lua +++ b/.config/nvim/lua/plugins/lsp/lspconfig.lua @@ -1,131 +1,131 @@ return { - 'neovim/nvim-lspconfig', - event = { 'BufReadPost', 'BufNewFile' }, - dependencies = { - 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', - 'hrsh7th/cmp-nvim-lsp', - { 'antosha417/nvim-lsp-file-operations', config = true }, - { 'folke/neodev.nvim', config = true }, - }, + 'neovim/nvim-lspconfig', + event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' }, + dependencies = { + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'hrsh7th/cmp-nvim-lsp', + { 'antosha417/nvim-lsp-file-operations', config = true }, + { 'folke/neodev.nvim', config = true }, + }, - config = function() - local lspconfig = require('lspconfig') - local mason_lspconfig = require('mason-lspconfig') - local cmp_nvim_lsp = require('cmp_nvim_lsp') - local keymap = vim.keymap + config = function() + local lspconfig = require('lspconfig') + local mason_lspconfig = require('mason-lspconfig') + local cmp_nvim_lsp = require('cmp_nvim_lsp') + local keymap = vim.keymap - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('UserLspConfig', {}), - callback = function(ev) - local opts = { buffer = ev.buf, silent = true } + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + local opts = { buffer = ev.buf, silent = true } - opts.desc = 'Show LSP references' - keymap.set('n', 'gR', 'Telescope lsp_references', opts) + opts.desc = 'Show LSP references' + keymap.set('n', 'gR', 'Telescope lsp_references', opts) - opts.desc = 'Go to declaration' - keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + opts.desc = 'Go to declaration' + keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) - opts.desc = 'Show LSP definitions' - keymap.set('n', 'gd', 'Telescope lsp_definitions', opts) + opts.desc = 'Show LSP definitions' + keymap.set('n', 'gd', 'Telescope lsp_definitions', opts) - opts.desc = 'Show LSP implementations' - keymap.set('n', 'gi', 'Telescope lsp_implementations', opts) + opts.desc = 'Show LSP implementations' + keymap.set('n', 'gi', 'Telescope lsp_implementations', opts) - opts.desc = 'Show LSP type definitions' - keymap.set('n', 'gt', 'Telescope lsp_type_definitions', opts) + opts.desc = 'Show LSP type definitions' + keymap.set('n', 'gt', 'Telescope lsp_type_definitions', opts) - opts.desc = 'See available code actions' - keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + opts.desc = 'See available code actions' + keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) - opts.desc = 'Smart rename' - keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + opts.desc = 'Smart rename' + keymap.set('n', 'rn', vim.lsp.buf.rename, opts) - opts.desc = 'Show buffer diagnostics' - keymap.set('n', 'D', 'Telescope diagnostics bufnf=0', opts) + opts.desc = 'Show buffer diagnostics' + keymap.set('n', 'D', 'Telescope diagnostics bufnf=0', opts) - opts.desc = 'Show line diagnostics' - keymap.set('n', 'd', vim.diagnostic.open_float, opts) + opts.desc = 'Show line diagnostics' + keymap.set('n', 'd', vim.diagnostic.open_float, opts) - opts.desc = 'Go to previous diagnostic' - keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) + opts.desc = 'Go to previous diagnostic' + keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) - opts.desc = 'Go to next diagnostic' - keymap.set('n', ']d', vim.diagnostic.goto_next, opts) + opts.desc = 'Go to next diagnostic' + keymap.set('n', ']d', vim.diagnostic.goto_next, opts) - opts.desc = 'Show documentation for what is under cursor' - keymap.set('n', 'K', vim.lsp.buf.hover, opts) + opts.desc = 'Show documentation for what is under cursor' + keymap.set('n', 'K', vim.lsp.buf.hover, opts) - opts.desc = 'Restart LSP' - keymap.set('n', 'rs', ':LspRestart', opts) - end, - }) + opts.desc = 'Restart LSP' + keymap.set('n', 'rs', ':LspRestart', opts) + end, + }) - local capabilities = cmp_nvim_lsp.default_capabilities() + local capabilities = cmp_nvim_lsp.default_capabilities() - local signs = { Error = ' ', Warn = ' ', Hint = '󰠠 ', Info = ' ' } - for type, icon in pairs(signs) do - local hl = 'DiagnosticSign' .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) - end + local signs = { Error = ' ', Warn = ' ', Hint = '󰠠 ', Info = ' ' } + for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) + end - mason_lspconfig.setup_handlers({ - -- default handler for installed servers - function(server_name) - lspconfig[server_name].setup({ - capabilities = capabilities, - }) - end, - ['emmet_ls'] = function() - -- configure emmet language server - lspconfig['emmet_ls'].setup({ - capabilities = capabilities, - filetypes = { 'html', 'typescriptreact', 'javascriptreact', 'css', 'sass', 'scss', 'less', 'svelte' }, - }) - end, - ['bashls'] = function() - lspconfig['bashls'].setup({ - capabilities = capabilities, - filetypes = { 'sh', 'bash', 'zsh' }, - }) - end, - ['lua_ls'] = function() - -- configure lua server (with special settings) - lspconfig['lua_ls'].setup({ - capabilities = capabilities, - settings = { - Lua = { - -- make the language server recognize "vim" global - diagnostics = { - globals = { 'vim' }, - }, - completion = { - callSnippet = 'Replace', - }, - }, - }, - }) - end, - }) + mason_lspconfig.setup_handlers({ + -- default handler for installed servers + function(server_name) + lspconfig[server_name].setup({ + capabilities = capabilities, + }) + end, + ['emmet_ls'] = function() + -- configure emmet language server + lspconfig['emmet_ls'].setup({ + capabilities = capabilities, + filetypes = { 'html', 'typescriptreact', 'javascriptreact', 'css', 'sass', 'scss', 'less', 'svelte' }, + }) + end, + ['bashls'] = function() + lspconfig['bashls'].setup({ + capabilities = capabilities, + filetypes = { 'sh', 'bash', 'zsh' }, + }) + end, + ['lua_ls'] = function() + -- configure lua server (with special settings) + lspconfig['lua_ls'].setup({ + capabilities = capabilities, + settings = { + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { 'vim' }, + }, + completion = { + callSnippet = 'Replace', + }, + }, + }, + }) + end, + }) - vim.diagnostic.config({ - virtual_text = { - prefix = '●', - }, - signs = { - active = signs, - }, - update_in_insert = true, - underline = true, - severity_sort = true, - float = { - focusable = false, - style = 'minimal', - border = 'rounded', - source = true, - show_header = true, - prefix = '', - }, - }) - end, -} + vim.diagnostic.config({ + virtual_text = { + prefix = '●', + }, + signs = { + active = signs, + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = false, + style = 'minimal', + border = 'rounded', + source = true, + show_header = true, + prefix = '', + }, + }) + end, +} \ No newline at end of file