From 85dfb90e8359651812c04917a7b57c785f0a514c Mon Sep 17 00:00:00 2001 From: Nami Lauckner Date: Fri, 31 Jul 2026 20:12:38 +0200 Subject: [PATCH] working lsp and documentation --- after/plugin/harpoon.lua | 3 + after/plugin/lsp.lua | 44 ++++++++----- after/plugin/presense.lua | 8 --- after/plugin/telescope.lua | 30 ++++----- lazy-lock.json | 24 +++++++ logos.txt | 12 ---- lua/nami/autocmd.lua | 16 ++++- lua/nami/lazy.lua | 27 +++++++- lua/nami/remap.lua | 125 ++++++++++++++++--------------------- lua/nami/set.lua | 7 +-- 10 files changed, 168 insertions(+), 128 deletions(-) create mode 100644 lazy-lock.json delete mode 100644 logos.txt diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua index 8016bee..ce99f72 100644 --- a/after/plugin/harpoon.lua +++ b/after/plugin/harpoon.lua @@ -2,9 +2,12 @@ local harpoon = require("harpoon") harpoon:setup() +-- add buffer to the harpoon buffer vim.keymap.set("n", "a", function() harpoon:list():add() end) +-- show current harpoon buffer vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) +-- access harpoon buffer by index vim.keymap.set("n", "", function() harpoon:list():select(1) end) vim.keymap.set("n", "", function() harpoon:list():select(2) end) vim.keymap.set("n", "", function() harpoon:list():select(3) end) diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 9fa33d9..8606b76 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -1,15 +1,29 @@ vim.diagnostic.config({ - virtual_text = true, - signs = true, + virtual_text = true, -- Text to the right of issues + signs = false, underline = true, }) +-- Filetype by extension +vim.filetype.add { + extension = { + jinja = 'jinja', + jinja2 = 'jinja', + j2 = 'jinja', + py = 'python' + }, +} + +-- Languageserver config overrides +-- To enable a server a config must be present here +-- Default Configs are provided by nvim_lspconfig local servers = { + -- = { }, ts_ls = {}, eslint = {}, - lua_ls = { - cmd = { "lua-language-server" }, - filetypes = { "lua" } + lua_ls = {}, + jinja_lsp = { + filetypes = { 'jinja', 'rust', 'python' }, }, rust_analyzer = {}, ast_grep = {}, @@ -23,32 +37,33 @@ for server, config in pairs(servers) do vim.lsp.enable(server) end +local builtin = require('telescope.builtin'); vim.api.nvim_create_autocmd("LspAttach", { callback = function(args) local opts = { buffer = args.buf } - vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) -- Show type and defintion data (C-w C-w to enter it like any other buffer) + vim.keymap.set("n", "d", vim.diagnostic.open_float, opts) -- Show a detailed error description (can be run on lines with any error) + vim.keymap.set("n", "gd", builtin.lsp_definitions, opts) -- Go to definition + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- Rename symbol under cursor project wide through ls + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) -- Execute a ls code action -- vim.keymap.set("n", "[d", function() vim.diagnostic.jump({ count = 1, float = true }) end, opts) -- vim.keymap.set("n", "]d", function() vim.diagnostic.jump({ count = -1, float = true }) end, opts) - vim.keymap.set("n", "d", vim.diagnostic.open_float, opts) end }) +-- Does code completion local cmp = require("cmp") - cmp.setup({ window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.confirm(), + [""] = cmp.mapping.select_next_item(), -- Scroll down + [""] = cmp.mapping.select_prev_item(), -- Scroll Up + [""] = cmp.mapping.confirm(), -- Confirm currently suggested code completion }), sources = { { name = "nvim_lsp" }, @@ -56,6 +71,7 @@ cmp.setup({ } }) +-- Mason is only used for managing Languageserver binaries. Run :MasonInstallAll on first install require("mason").setup() local ensure_installed = { diff --git a/after/plugin/presense.lua b/after/plugin/presense.lua index 29ac871..fc1bf59 100644 --- a/after/plugin/presense.lua +++ b/after/plugin/presense.lua @@ -23,14 +23,6 @@ require("presence").setup({ local is_presence_active = true --- vim.api.nvim_create_autocmd("VimEnter", { --- callback = function() --- local presence = package.loaded.presence --- presence:cancel() --- is_presence_active = false --- end, --- }) - function ToggleDiscordPresence() local presence = package.loaded.presence if is_presence_active then diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index a873831..3728534 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -1,19 +1,4 @@ local builtin = require('telescope.builtin'); - -vim.keymap.set("n", "pf", function() - builtin.find_files({ - hidden = true, - file_ignore_patterns = { "%.git/", "%.cache", "dist/", "target/", ".vscode/", "node_modules/", "%.o", "lazy-lock.json" } - }); -end, {}); -vim.keymap.set('n', 'bf', builtin.buffers, { desc = 'Telescope buffers' }); -vim.keymap.set("n", "", builtin.git_files, {}); -vim.keymap.set("n", "pl", builtin.live_grep, {}); -vim.keymap.set("n", "pd", builtin.diagnostics, {}); -vim.keymap.set("n", "ps", function() - builtin.grep_string({ search = vim.fn.input("Grep > ") }); -end); - local actions = require('telescope.actions'); require("telescope").setup({ @@ -36,3 +21,18 @@ require("telescope").setup({ -- layout_strategy = "vertical", }, }); + +vim.keymap.set("n", "pf", function() + builtin.find_files({ + hidden = true, + file_ignore_patterns = { "%.git/", "%.cache", "dist/", "target/", ".vscode/", "node_modules/", "%.o", "lazy-lock.json" } + }); +end, {}); +vim.keymap.set('n', 'bf', builtin.buffers, { desc = 'Telescope buffers' }); +vim.keymap.set("n", "", builtin.git_files, {}); +vim.keymap.set("n", "pl", builtin.live_grep, {}); +vim.keymap.set("n", "pd", builtin.diagnostics, {}); +vim.keymap.set("n", "ps", function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }); +end); + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..f5a268d --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,24 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "642b0c595e11608b4c18219e93b88d7637af27bc" }, + "alpha-nvim": { "branch": "main", "commit": "6c6a89d5b068b5251c8bdf0dd57bb921bcfeeb09" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, + "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, + "mini.icons": { "branch": "main", "commit": "98faae31e9be1cc054ae63485e58ceb185efcad0" }, + "nvim-cmp": { "branch": "main", "commit": "2ffe79f1f021def8dd1fcd81deb16f1bb0d989f3" }, + "nvim-ghost.nvim": { "branch": "main", "commit": "bdba2a8ad0eec84379d65e7aa9b76a17b11b653a" }, + "nvim-lspconfig": { "branch": "master", "commit": "9ae2b3b63b924b1329724dae76e9d2c5c40b389c" }, + "nvim-treesitter": { "branch": "main", "commit": "0f32dff7f19476629c77467f887b95e5e2d33509" }, + "oil.nvim": { "branch": "master", "commit": "b73018b75affd13fa38e2fc94ef753b465f770d7" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "rose-pine": { "branch": "main", "commit": "ff483051a47e27d84bdef47703538df1ed9f4a47" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, + "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, + "undotree": { "branch": "master", "commit": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d" }, + "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, + "vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" } +} diff --git a/logos.txt b/logos.txt deleted file mode 100644 index c8c83df..0000000 --- a/logos.txt +++ /dev/null @@ -1,12 +0,0 @@ - -  - ████ ██████ █████ ██ - ███████████ █████  - █████████ ███████████████████ ███ ███████████ - █████████ ███ █████████████ █████ ██████████████ - █████████ ██████████ █████████ █████ █████ ████ █████ - ███████████ ███ ███ █████████ █████ █████ ████ █████ - ██████ █████████████████████ ████ █████ █████ ████ ██████ - - - diff --git a/lua/nami/autocmd.lua b/lua/nami/autocmd.lua index d66a3fa..8b0d7e7 100644 --- a/lua/nami/autocmd.lua +++ b/lua/nami/autocmd.lua @@ -61,7 +61,7 @@ vim.api.nvim_create_autocmd('FileType', { pattern = 'qf', callback = function() -- Do not show quickfix in buffer lists. - vim.api.nvim_buf_set_option(0, 'buflisted', false) + -- vim.api.nvim_set_opt('buflisted', false) -- Escape closes quickfix window. vim.keymap.set( @@ -77,3 +77,17 @@ vim.api.nvim_create_autocmd('FileType', { end, desc = 'Quickfix tweaks', }) + +-- @source https://github.com/benlubas/.dotfiles/blob/main/nvim%2Fafter%2Fftplugin%2Fqf.lua +local del_qf_item = function() + local items = vim.fn.getqflist() + local line = vim.fn.line('.') + table.remove(items, line) + vim.fn.setqflist(items, "r") + vim.api.nvim_win_set_cursor(0, { line, 0 }) +end + +-- this is super basic. I might improve it at some point, but it's good enough for how little I use +-- the QF list +vim.keymap.set("n", "dd", del_qf_item, { silent = true, buffer = true, desc = "Remove entry from QF" }) +vim.keymap.set("v", "D", del_qf_item, { silent = true, buffer = true, desc = "Remove entry from QF" }) diff --git a/lua/nami/lazy.lua b/lua/nami/lazy.lua index 9619366..bf11b3f 100755 --- a/lua/nami/lazy.lua +++ b/lua/nami/lazy.lua @@ -14,13 +14,15 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) +-- Due to Telescope loading too fast this must be configured here vim.g.mapleader = " " local plugins = { { "nvim-telescope/telescope.nvim", version = "0.2.1", - dependencies = { { "nvim-lua/plenary.nvim" }, + dependencies = { + { "nvim-lua/plenary.nvim" }, { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, }, }, @@ -43,6 +45,7 @@ local plugins = { lazy = true }, { + -- Use Neovim to input into Browser Textfields "subnut/nvim-ghost.nvim", lazy = true }, @@ -67,6 +70,26 @@ local plugins = { { "williamboman/mason.nvim" }, { "hrsh7th/cmp-nvim-lsp" }, { "hrsh7th/nvim-cmp" }, + { + "L3MON4D3/LuaSnip", + version = "v2.*", -- Replace by the latest released major (first number of latest release) + }, + { + "neovim/nvim-lspconfig", + lazy = false, + }, + { + "folke/lazydev.nvim", + ft = "lua", + opts = { + library = { + { + path = "${3rd}/luv/library", + words = { "vim%.uv" }, + }, + }, + }, + }, { "goolord/alpha-nvim", lazy = true, @@ -75,4 +98,4 @@ local plugins = { }, } -require("lazy").setup(plugins, {}) +require("lazy").setup(plugins, { debug = true }) diff --git a/lua/nami/remap.lua b/lua/nami/remap.lua index 0dbc9a1..365f4cf 100644 --- a/lua/nami/remap.lua +++ b/lua/nami/remap.lua @@ -1,65 +1,44 @@ -vim.g.mapleader = " " +-- vim.g.mapleader = " " +-- This has to be configured inside lazy.lua due to telescope loading before this takes effect vim.cmd("command! W w") -vim.api.nvim_create_user_command("Mdtf", function(opts) - vim.cmd(string.format("%d,%d!column -t -s '|' -o '|'", opts.line1, opts.line2)) -end, { - range = true, -}) -vim.keymap.set("v", "mt", ":!column -t -s '|' -o '|'", { desc = "Format markdown table" }) +-- Navigation +vim.keymap.set("n", "Q", "", { desc = "Do not quit" }) -- Do not quit :D +vim.keymap.set("i", "", "") -- Exit insert mode with C-c +vim.keymap.set("n", "", "silent !tmux display-popup -E \"tmuxss -i\"") -- open tmuxss switcher +vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) -- open file viewer +vim.keymap.set("n", "", "copen"); -- Open Quickfixlist --- Macros +vim.keymap.set("t", "", "") -- use Esc to escape terminal -vim.keymap.set("t", "", "") --- tnoremap +vim.keymap.set("n", "", "zz") -- Move up a page while keeping the cursor centered +vim.keymap.set("n", "", "zz") -- Move down a page while keeping the cursor centered -vim.keymap.set("n", "c", ":w:!cargorun") +vim.keymap.set("n", "n", "nzzzv") -- Jump to next occurance and center cursor +vim.keymap.set("n", "N", "Nzzzv") -- Jump to previous occurance and center cursor --- vim.keymap.set("n", "pv", vim.cmd.Ex) -vim.keymap.set("n", "pv", "Oil", { desc = "Open parent directory" }) -vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) -vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) +vim.keymap.set("n", "", "cprevzz") -- Previous Quickfixlist entry +vim.keymap.set("n", "", "cnextzz") -- Next Quickfixlist entry -vim.keymap.set("v", "J", ":m '>+1gv=gv") -vim.keymap.set("v", "K", ":m '<-2gv=gv") +vim.keymap.set("n", "", "tabnext +") -- Next tab +vim.keymap.set("n", "", "tabnext -") -- Previous Tab +vim.keymap.set("n", "", "tabnew") -- Create new Tab +vim.keymap.set("n", "", "tabclose") -- Close the current Tab -vim.keymap.set("n", "J", "mzJ`z") -vim.keymap.set("n", "", "zz") -vim.keymap.set("n", "", "zz") -vim.keymap.set("n", "n", "nzzzv") -vim.keymap.set("n", "N", "Nzzzv") +-- Text editing +vim.keymap.set("v", "J", ":m '>+1gv=gv") -- Move selected text up one line +vim.keymap.set("v", "K", ":m '<-2gv=gv") -- Move selected text down one line --- greatest remap ever -vim.keymap.set("x", "P", "\"_dP") -vim.keymap.set("x", "p", "\"_dp") +vim.keymap.set("n", "J", "mzJ`z") -- Remove newline characte on current line --- next greatest remap ever : asbjornHaland --- to void register (system) -vim.keymap.set("n", "y", "\"+y") -vim.keymap.set("v", "y", "\"+y") -vim.keymap.set("n", "Y", "\"+Y") -vim.keymap.set("v", "d", "\"_d") -vim.keymap.set("v", "dd", "\"_d") +vim.keymap.set("n", "c", ":w:!cargorun") -- Quick Cargo run -vim.keymap.set("n", "", "\"\"i"); - --- This is going to get me cancelled -vim.keymap.set("i", "", "") - -vim.keymap.set("n", "Q", "") -vim.keymap.set("n", "", "silent !tmux display-popup -E \"tmuxss -i\"") vim.keymap.set("n", "f", function() vim.lsp.buf.format() end) -vim.keymap.set("n", "", "cprevzz") -vim.keymap.set("n", "", "cnextzz") --- vim.keymap.set("n", "k", "lnextzz") --- vim.keymap.set("n", "j", "lprevzz") - -vim.keymap.set("n", "s", ":%s/\\<\\>//gI") - +-- fuck this thing for _, mode in ipairs({ "n", "v", "i" }) do vim.keymap.set(mode, "", function() end) vim.keymap.set(mode, "<2-RightMouse>", function() end) @@ -67,16 +46,36 @@ for _, mode in ipairs({ "n", "v", "i" }) do vim.keymap.set(mode, "<4-RightMouse>", function() end) end -vim.keymap.set("n", "", "tabnext +") -vim.keymap.set("n", "", "tabnext -") -vim.keymap.set("n", "", "tabnew") --- vim.keymap.del("n", "d") --- vim.keymap.del("n", "") -vim.keymap.set("n", "", "tabclose") +-- Goated: Edit the word under the cursor using a substitute +vim.keymap.set("n", "s", ":%s/\\<\\>//gI") -vim.keymap.set("n", "l", "source %") -vim.keymap.set("n", "l", ":.lua") -vim.keymap.set("v", "l", ":lua") +-- Yanking and Pasting +-- Yank to + register (system clipboard) +vim.keymap.set("n", "y", "\"+y") +vim.keymap.set("v", "y", "\"+y") +vim.keymap.set("n", "Y", "\"+Y") +-- Delete to void register (no clipboard) +vim.keymap.set("v", "d", "\"_d") +vim.keymap.set("v", "dd", "\"_d") +-- currently conflict with searches +-- vim.keymap.set("x", "P", "\"_dP") -- Paste before without moving selection into the yank register +-- vim.keymap.set("x", "p", "\"_dp") -- Paste after without moving selection into the yank register + +-- Macros +vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) + +-- format a markdown table inside visual selection +vim.api.nvim_create_user_command("Mdtf", function(opts) + vim.cmd(string.format("%d,%d!column -t -s '|' -o '|'", opts.line1, opts.line2)) +end, { + range = true, +}) +vim.keymap.set("v", "mt", ":!column -t -s '|' -o '|'", { desc = "Format markdown table" }) + +-- Lua editing +vim.keymap.set("n", "l", "source %") -- source the current buffer +vim.keymap.set("n", "l", ":.lua") -- source the current line +vim.keymap.set("v", "l", ":lua") -- source the visual selection local function swap_words() local start = vim.fn.getpos("'<")[2] @@ -103,19 +102,3 @@ end vim.keymap.set("v", "ws", swap_words, { desc = "Swap two words in selection" }) vim.keymap.set("n", "ws", swap_words, { desc = "Swap two words in selection" }) - --- @source https://github.com/benlubas/.dotfiles/blob/main/nvim%2Fafter%2Fftplugin%2Fqf.lua -local del_qf_item = function() - local items = vim.fn.getqflist() - local line = vim.fn.line('.') - table.remove(items, line) - vim.fn.setqflist(items, "r") - vim.api.nvim_win_set_cursor(0, { line, 0 }) -end - --- this is super basic. I might improve it at some point, but it's good enough for how little I use --- the QF list -vim.keymap.set("n", "dd", del_qf_item, { silent = true, buffer = true, desc = "Remove entry from QF" }) -vim.keymap.set("v", "D", del_qf_item, { silent = true, buffer = true, desc = "Remove entry from QF" }) - -vim.keymap.set("n", "", "copen"); diff --git a/lua/nami/set.lua b/lua/nami/set.lua index 0c05fdc..507108b 100644 --- a/lua/nami/set.lua +++ b/lua/nami/set.lua @@ -1,11 +1,8 @@ -- no more warnings -vim.deprecate = function() end +-- vim.deprecate = function() end -- vim.opt.guicursor = "" --- disable netrw header -vim.g.netrw_banner = 0 - vim.opt.nu = true vim.opt.relativenumber = true @@ -18,7 +15,7 @@ vim.opt.expandtab = true vim.opt.smartindent = true -vim.opt.wrap = true--false +vim.opt.wrap = true -- vim.opt.linebreak = true vim.opt.swapfile = false