diff --git a/home/modules/nvim/config/lua/dnsc/lsp.lua b/home/modules/nvim/config/lua/dnsc/lsp.lua index e6ffe7e..3e3f3ff 100644 --- a/home/modules/nvim/config/lua/dnsc/lsp.lua +++ b/home/modules/nvim/config/lua/dnsc/lsp.lua @@ -2,3 +2,21 @@ vim.lsp.enable("ts_ls") vim.lsp.enable("lua_ls") vim.lsp.enable("eslint") vim.lsp.enable("jsonls") + +vim.diagnostic.config({ + virtual_text = false, + signs = true, + underline = true, + update_in_insert = false, + severity_sort = false, +}) + +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local opts = { buffer = args.buf } + + vim.keymap.set("n", "", "", opts) + vim.keymap.set("n", "e", "vim.diagnostic.open_float()", opts) + vim.keymap.set("n", "ca", "lua vim.lsp.buf.code_action()", opts) + end, +}) diff --git a/home/modules/nvim/config/lua/plugins/blink.lua b/home/modules/nvim/config/lua/plugins/blink.lua index 7fcfa21..66c1a7a 100644 --- a/home/modules/nvim/config/lua/plugins/blink.lua +++ b/home/modules/nvim/config/lua/plugins/blink.lua @@ -5,7 +5,12 @@ return { ---@module 'blink.cmp' ---@type blink.cmp.Config opts = { - keymap = { preset = "enter" }, -- 'default' | 'super-tab' | 'enter' + keymap = { + preset = "enter", + [""] = { "select_next", "fallback" }, + [""] = { "select_prev", "fallback" }, + [""] = { "show_documentation", "hide_documentation" }, + }, appearance = { nerd_font_variant = "mono", }, diff --git a/home/modules/nvim/config/lua/plugins/fzf-lua.lua b/home/modules/nvim/config/lua/plugins/fzf-lua.lua deleted file mode 100644 index b69b881..0000000 --- a/home/modules/nvim/config/lua/plugins/fzf-lua.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - "ibhagwan/fzf-lua", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = {}, -} \ No newline at end of file diff --git a/home/modules/nvim/config/lua/plugins/lsp.lua.archive b/home/modules/nvim/config/lua/plugins/lsp.lua.archive deleted file mode 100644 index c4d20f9..0000000 --- a/home/modules/nvim/config/lua/plugins/lsp.lua.archive +++ /dev/null @@ -1,276 +0,0 @@ -return { - "neovim/nvim-lspconfig", - version = "0.1.9", - dependencies = { - "L3MON4D3/LuaSnip", - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/nvim-cmp", - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - "b0o/schemastore.nvim", - }, - config = function() - local lspconfig = require("lspconfig") - local luasnip = require("luasnip") - local dnscUtils = require("dnsc.utils") - local lspUtils = require("lspconfig.util") - local cmp = require("cmp") - local capabilities = require("cmp_nvim_lsp").default_capabilities() - - local servers = { - "eslint", - "angularls", - "ts_ls", - "lua_ls", - "jsonls", - "html", - "cssls", - "tailwindcss", - "gopls", - "astro", - "tinymist", - "ols", - } - - require("mason").setup() - -- Automatic Server Installation with Mason - require("mason-lspconfig").setup({ - ensure_installed = servers, - automatic_installation = true, - }) - - -- LANGUAGE SERVERS - -- Lua - lspconfig.lua_ls.setup({ - capabilities = capabilities, - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - telemetry = { - enable = false, - }, - }, - }, - }) - - -- Typescript - lspconfig.tsserver.setup({ - capabilities = capabilities, - root_dir = lspUtils.root_pattern("package.json"), - init_options = { - preferences = { - importModuleSpecifierPreference = "relative", - importModuleSpecifierEnding = "minimal", - }, - }, - handlers = { - ["textDocument/definition"] = function(err, result, method, ...) - if vim.tbl_islist(result) and #result > 1 then - local filtered_result = dnscUtils.filter(result, dnscUtils.filterReactDTS) - return vim.lsp.handlers["textDocument/definition"](err, filtered_result, method, ...) - end - - vim.lsp.handlers["textDocument/definition"](err, result, method, ...) - end, - }, - }) - - -- JSON - lspconfig.jsonls.setup({ - capabilities = capabilities, - settings = { - json = { - schemas = require("schemastore").json.schemas(), - validate = { enable = true }, - }, - }, - }) - - -- HTML - lspconfig.html.setup({ - capabilities = capabilities, - }) - - -- Astro - lspconfig.astro.setup({}) - - -- Tailwind - lspconfig.tailwindcss.setup({}) - - -- Typst - lspconfig.tinymist.setup({ - single_file_support = true, - root_dir = function() - return vim.fn.getcwd() - end, - settings = {}, - }) - - -- CSS - lspconfig.cssls.setup({}) - - -- Angular - lspconfig.angularls.setup({}) - - -- ESLint - lspconfig.eslint.setup({}) - - -- Go - lspconfig.gopls.setup({ - capabilities = capabilities, - }) - - -- Run gofmt + goimports on save - local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) - vim.api.nvim_create_autocmd("BufWritePre", { - pattern = "*.go", - callback = function() - require("go.format").goimports() - end, - group = format_sync_grp, - }) - - -- Odin - lspconfig.ols.setup({}) - - -- LSP Keybindings - -- Global mappings. - -- See `:help vim.diagnostic.*` for documentation on any of the below functions - vim.keymap.set("n", "e", vim.diagnostic.open_float) - vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) - vim.keymap.set("n", "]d", vim.diagnostic.goto_next) - vim.keymap.set("n", "q", vim.diagnostic.setloclist) - - -- Use LspAttach autocommand to only map the following keys - -- after the language server attaches to the current buffer - vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("UserLspConfig", {}), - callback = function(ev) - -- Enable completion triggered by - vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" - - -- Buffer local mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local opts = { buffer = ev.buf } - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) - vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) - vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) - vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) - vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) - vim.keymap.set("n", "f", function() - vim.lsp.buf.format({ async = true }) - end, opts) - end, - }) - - cmp.setup({ - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) -- For `luasnip` users. - end, - }, - formatting = { - format = function(entry, vim_item) - -- Kind icons - vim_item.kind = string.format("%s ", vim_item.kind) -- This concatenates the icons with the name of the item kind - -- Source - vim_item.menu = ({ - buffer = "[Buffer]", - nvim_lsp = "[LSP]", - luasnip = "[Snip]", - nvim_lua = "[Lua]", - })[entry.source.name] - return vim_item - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - if luasnip.expandable() then - luasnip.expand() - else - cmp.confirm({ - select = true, - }) - end - else - fallback() - end - end), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.locally_jumpable(1) then - luasnip.jump(1) - else - fallback() - end - end, { "i", "s" }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - sources = cmp.config.sources({ - { name = "nvim_lsp", keyword_length = 1 }, - { name = "path" }, - { name = "buffer", keyword_length = 3 }, - { name = "luasnip" }, -- For luasnip users. - { name = "render-markdown" }, - }), - }) - - -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline({ "/", "?" }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, - }, - }) - - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "path" }, - }, { - { name = "cmdline" }, - }), - }) - - -- Set up vim-dadbod completions - cmp.setup.filetype({ "sql", "mysql", "psql" }, { - sources = { - { name = "vim-dadbod-completion" }, - { name = "buffer" }, - }, - }) - - -- Set up org mode - cmp.setup.filetype({ "org" }, { - sources = { - { name = "orgmode" }, - }, - }) - end, -} diff --git a/home/modules/nvim/config/lua/plugins/snacks.lua b/home/modules/nvim/config/lua/plugins/snacks.lua index a72c6a4..787d3c9 100644 --- a/home/modules/nvim/config/lua/plugins/snacks.lua +++ b/home/modules/nvim/config/lua/plugins/snacks.lua @@ -26,6 +26,12 @@ return { enabled = true, configure = true, }, + picker = { + enabled = true, + prompt = "λ ", + preset = "ivy", + layout = { position = "bottom" }, + }, statuscolumn = { enabled = true }, zen = { enabled = true }, }, @@ -36,6 +42,26 @@ return { { "gb", function() Snacks.git.blame_line() end, desc = "Show git blame for current line" }, { "gl", function() Snacks.gitbrowse() end, desc = "Open link to line at git remote" }, -- Zen Mode - { "z", function() Snacks.zen() end, desc = "Toggle Zen Mode" } + { "z", function() Snacks.zen() end, desc = "Toggle Zen Mode" }, + -- Picker + { "", function() end, desc = "" }, + { ".", function() Snacks.picker.files() end, desc = "" }, + { "", function() Snacks.picker.git_files() end, desc = "Git files" }, + -- Find + { "fr", function() Snacks.picker.recent() end, desc = "Recent" }, + { "fp", function() Snacks.picker.projects() end, desc = "Projects" }, + -- Search + { "ss", function() Snacks.picker.grep() end, desc = "Grep" }, + { "sw", function() Snacks.picker.grep_word() end, desc = "Visual selection or word", mode = { "n", "x" } }, + { "su", function() Snacks.picker.undo() end, desc = "Undo History" }, + -- Diagnostics + { "td", function() Snacks.picker.diagnostics_buffer() end, desc = "Buffer Diagnostics" }, + { "ta", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" }, + -- LSP + { "gd", function() Snacks.picker.lsp_definitions() end, desc = "Goto Definition" }, + { "gD", function() Snacks.picker.lsp_declarations() end, desc = "Goto Declaration" }, + { "grr", function() Snacks.picker.lsp_references() end, nowait = true, desc = "References" }, + { "gI", function() Snacks.picker.lsp_implementations() end, desc = "Goto Implementation" }, + { "gy", function() Snacks.picker.lsp_type_definitions() end, desc = "Goto T[y]pe Definition" }, }, } diff --git a/home/modules/nvim/config/lua/plugins/which-key.lua b/home/modules/nvim/config/lua/plugins/which-key.lua index 3829e5f..c0f233b 100644 --- a/home/modules/nvim/config/lua/plugins/which-key.lua +++ b/home/modules/nvim/config/lua/plugins/which-key.lua @@ -10,11 +10,7 @@ return { { "o", group = "open", mode = "n" }, { "ot", ":e ~/notes/todo.txt", desc = "Open todos", mode = "n" }, { "od", ":80 vsplit | :VimwikiMakeDiaryNote", desc = "Open diary note in split", mode = "n" }, - { ".", "FzfLua files", desc = "Find file in dir", mode = "n" }, - { "", "FzfLua git_files", desc = "Find git file", mode = "n" }, - { "B", "FzfLua buffers", desc = "Opens buffers", mode = "n" }, { "b", group = "buffer", mode = "n" }, - { "bb", "FzfLua buffers", desc = "Switches buffers", mode = "n" }, { "b,", "BufferMovePrevious", desc = "Move buffer back", mode = "n" }, { "b.", @@ -62,14 +58,6 @@ return { desc = "Run current project", mode = "n", }, - { "ca", "FzfLua lsp_code_actions", desc = "Code actions", mode = "n" }, - { "cd", "FzfLua diagnostics_document", desc = "Show diagnostics", mode = "n" }, - { - "cf", - "FzfLua lsp_references", - desc = "Show references", - mode = "n", - }, { "q", "wq", @@ -83,7 +71,6 @@ return { desc = "Create a new file", mode = "n", }, - { "fr", "FzfLua oldfiles", desc = "Open Recent File", mode = "n" }, { "fs", "w", @@ -92,21 +79,7 @@ return { }, { "q", "qa!", desc = "Leave neovim", mode = "n" }, { "s", group = "search", mode = "n" }, - { "ss", "FzfLua live_grep_native", desc = "Live Grep", mode = "n" }, - { "sp", "FzfLua grep_project", desc = "Grep in project", mode = "n" }, - { - "sw", - "FzfLua grep_cword", - desc = "Search current word", - mode = "n", - }, { "t", group = "diagnostics (lsp)", mode = "n" }, - { - "td", - "FzfLua diagnostics_document", - desc = "Show LSP diagnostics", - mode = "n", - }, { "ta", "TodoQuickFix", desc = "Show all todo comments", mode = "n" }, { "w", group = "window", mode = "n" }, { diff --git a/todo.txt b/todo.txt index 0b08756..7706499 100644 --- a/todo.txt +++ b/todo.txt @@ -1,7 +1,7 @@ -x Set up luals +x 2025-04-12 2025-03-01 Set up luals +config @home due:2025-05-01 x Set up eslint ls x Set up jsonls x Set up better (Enter vs. super-tab) keymaps for blink -Set up keymaps for LSP -Set up snacks picker instead of fzf +x Set up keymaps for LSP +x Set up snacks picker instead of fzf Set up lua dev environment