diff --git a/.config/nvim/lua/tsousa/init.lua b/.config/nvim/lua/tsousa/init.lua index 8edf891..f69e45a 100644 --- a/.config/nvim/lua/tsousa/init.lua +++ b/.config/nvim/lua/tsousa/init.lua @@ -30,7 +30,11 @@ autocmd('TextYankPost', { autocmd({ "BufWritePre" }, { group = TsousaGroup, pattern = "*", - command = [[%s/\s\+$//e]], + callback = function () + local cursor_pos = vim.fn.getpos('.') + vim.cmd([[%s/\s\+$//e]]) + vim.fn.setpos('.', cursor_pos) + end }) autocmd("LspAttach", { diff --git a/.config/nvim/lua/tsousa/plugins/lsp.lua b/.config/nvim/lua/tsousa/plugins/lsp.lua index 80d6567..058c696 100644 --- a/.config/nvim/lua/tsousa/plugins/lsp.lua +++ b/.config/nvim/lua/tsousa/plugins/lsp.lua @@ -29,11 +29,6 @@ return { require("luasnip.loaders.from_vscode").lazy_load() - local check_backspace = function() - local col = vim.fn.col "." - 1 - return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" - end - cmp.setup { snippet = { expand = function(args) @@ -54,20 +49,14 @@ return { ), [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function() if luasnip.expand_or_jumpable() then luasnip.expand_or_jump() - elseif check_backspace() then - fallback() - else - fallback() end end), - [""] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function() if luasnip.jumpable(-1) then luasnip.jump(-1) - else - fallback() end end ), @@ -210,6 +199,24 @@ return { } }) + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("TsousaLspConfig", {}), + callback = function(e) + local bufopts = { buffer = e.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, 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', 'wss', vim.lsp.buf.workspace_symbol, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'fo', function() vim.lsp.buf.format { async = true } end, bufopts) + vim.keymap.set('i', '', vim.lsp.buf.signature_help, bufopts) + end + }) + mason_lspconfig.setup({ ensure_installed = { lua_ls, @@ -224,11 +231,24 @@ return { }) end, -- add here other custom overrides + ["hls"] = function() + lspconfig.hls.setup({ + settings = { + haskell = { + plugin = { + stan = { globalOn = false }, + hlint = { config = { flags = { "--ignore=Eta reduce" } } } + } + } + } + }) + end, ["lua_ls"] = function() lspconfig.lua_ls.setup({ settings = { Lua = { - diagnostics = { globals = { "vim" } } + diagnostics = { globals = { "vim" } }, + telemetry = { enable = false } } } }) diff --git a/.config/nvim/lua/tsousa/plugins/todo-comments.lua b/.config/nvim/lua/tsousa/plugins/todo-comments.lua index f422c23..886f079 100644 --- a/.config/nvim/lua/tsousa/plugins/todo-comments.lua +++ b/.config/nvim/lua/tsousa/plugins/todo-comments.lua @@ -20,10 +20,6 @@ return { NOTE = { icon = " ", color = "hint", alt = { "INFO", "info", "note" } }, TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED", "test" } }, }, - gui_style = { - fg = "NONE", -- The gui style to use for the fg highlight group. - bg = "BOLD", -- The gui style to use for the bg highlight group. - }, merge_keywords = true, -- when true, custom keywords will be merged with the defaults -- highlighting of the line containing the todo comment -- * before: highlights before the keyword (typically comment characters) @@ -41,30 +37,6 @@ return { max_line_len = 400, -- ignore lines longer than this exclude = {}, -- list of file types to exclude highlighting }, - -- list of named colors where we try to extract the guifg from the - -- list of highlight groups or use the hex color if hl not found as a fallback - colors = { - error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, - warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" }, - info = { "DiagnosticInfo", "#2563EB" }, - hint = { "DiagnosticHint", "#10B981" }, - default = { "Identifier", "#7C3AED" }, - test = { "Identifier", "#FF00FF" } - }, - search = { - command = "rg", - args = { - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - }, - -- regex that will be used to match keywords. - -- don't replace the (KEYWORDS) placeholder - pattern = [[\b(KEYWORDS):]], -- ripgrep regex - -- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives - }, }) end }