From 2baaa449cf19e0f31f43a093367457e9546e3d56 Mon Sep 17 00:00:00 2001 From: Noah Pederson Date: Mon, 23 Mar 2026 19:05:03 -0500 Subject: [PATCH] Clean up lua LSP and gitsigns in neovim --- flake.nix | 1 + nvim/lua/lsp/lua_ls.lua | 9 ++++- nvim/lua/plugins.lua | 85 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 86 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 9233fb7..e9e0973 100644 --- a/flake.nix +++ b/flake.nix @@ -246,6 +246,7 @@ inherit (self.checks.${system}.pre-commit-check) shellHook; buildInputs = [ nixpkgs.legacyPackages.${system}.nixfmt-rfc-style + nixpkgs-unstable.legacyPackages.${system}.lua-language-server ] ++ self.checks.${system}.pre-commit-check.enabledPackages; }; diff --git a/nvim/lua/lsp/lua_ls.lua b/nvim/lua/lsp/lua_ls.lua index fa9700a..0dd02ff 100644 --- a/nvim/lua/lsp/lua_ls.lua +++ b/nvim/lua/lsp/lua_ls.lua @@ -14,7 +14,14 @@ return { library = vim.api.nvim_get_runtime_file("", true) }, -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { enable = false } + telemetry = { enable = false }, + format = { + enable = true, + defaultConfig = { + indent_style = "tab", + indent_size = "1", + } + } } } } diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 607c78e..318c2e0 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -289,8 +289,9 @@ require("lazy").setup({ config = function() require("crates").setup() end, lazy = true, ft = { "rust" } - }, -- RISC-V Assembly syntax highlighting - { "kylelaker/riscv.vim", ft = "riscv" }, -- Hare Stuff + }, + -- RISC-V Assembly syntax highlighting + { "kylelaker/riscv.vim", ft = "riscv" }, -- Hare stuff -- Haredoc { @@ -334,14 +335,82 @@ require("lazy").setup({ vim.keymap.set({ "n", "x" }, "sr", function() ssr.open() end) end }, - { "lewis6991/gitsigns.nvim", config = true }, { - "greggh/claude-code.nvim", - dependencies = { - "nvim-lua/plenary.nvim" - }, - config = true + "lewis6991/gitsigns.nvim", + config = true, + opts = { + on_attach = function(bufnr) + local gitsigns = require('gitsigns') + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal({ ']c', bang = true }) + else + gitsigns.nav_hunk('next') + end + end) + + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal({ '[c', bang = true }) + else + gitsigns.nav_hunk('prev') + end + end) + + -- Actions + map('n', 'hs', gitsigns.stage_hunk) + map('n', 'hr', gitsigns.reset_hunk) + + map('v', 'hs', function() + gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + end) + + map('v', 'hr', function() + gitsigns.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + end) + + map('n', 'hS', gitsigns.stage_buffer) + map('n', 'hR', gitsigns.reset_buffer) + map('n', 'hp', gitsigns.preview_hunk) + map('n', 'hi', gitsigns.preview_hunk_inline) + + map('n', 'hb', function() + gitsigns.blame_line({ full = true }) + end) + + map('n', 'hd', gitsigns.diffthis) + + map('n', 'hD', function() + gitsigns.diffthis('~') + end) + + map('n', 'hQ', function() gitsigns.setqflist('all') end) + map('n', 'hq', gitsigns.setqflist) + + -- Toggles + map('n', 'tb', gitsigns.toggle_current_line_blame) + map('n', 'tw', gitsigns.toggle_word_diff) + + -- Text object + map({ 'o', 'x' }, 'ih', gitsigns.select_hunk) + end + } }, + --{ + -- "greggh/claude-code.nvim", + -- dependencies = { + -- "nvim-lua/plenary.nvim" + -- }, + -- config = true + --}, { "Bowuigi/acme-nvim", config = function() -- 2.51.2