From f6a12c9a9ffa33b3146fa0cd330c79b4a7178ba7 Mon Sep 17 00:00:00 2001 From: jordanyono Date: Mon, 4 May 2026 23:01:25 -0400 Subject: [PATCH] low hanging fixes --- lua/custom/git_links.lua | 28 +++++++---- lua/plugins/kickstart/options.lua | 9 ++-- lua/plugins/kickstart/plugins/conform.lua | 24 ++------- lua/plugins/kickstart/plugins/lsp.lua | 50 ++----------------- .../kickstart/plugins/neotest_golang.lua | 21 -------- lua/plugins/kickstart/plugins/spec.lua | 2 +- lua/plugins/kickstart/plugins/toggleterm.lua | 26 ++++++++++ lua/plugins/kickstart/plugins/treesitter.lua | 1 - lua/plugins/kickstart/plugins/which_key.lua | 1 + 9 files changed, 58 insertions(+), 104 deletions(-) delete mode 100644 lua/plugins/kickstart/plugins/neotest_golang.lua create mode 100644 lua/plugins/kickstart/plugins/toggleterm.lua diff --git a/lua/custom/git_links.lua b/lua/custom/git_links.lua index 88155b03..5b547b66 100644 --- a/lua/custom/git_links.lua +++ b/lua/custom/git_links.lua @@ -10,29 +10,42 @@ Small, focused utility used by `plugins.kickstart.keymaps` (`go`). Kept under `custom/` so it stays clearly “yours” vs. generated plugin specs. - Dependencies: git(1), xdg-open (Linux); file must be tracked by git. + Dependencies: git(1); `vim.ui.open` on Nvim 0.10+, else `open` / `xdg-open` / `cmd start`. ]] local M = {} +---@param url string +local function open_url(url) + if vim.ui and vim.ui.open then + vim.ui.open(url) + return + end + local cmd + if vim.fn.has 'win32' == 1 then + cmd = { 'cmd', '/c', 'start', '', url } + elseif vim.fn.has 'macunix' == 1 then + cmd = { 'open', url } + else + cmd = { 'xdg-open', url } + end + vim.fn.jobstart(cmd, { detach = true }) +end + M.open_github = function() - -- Get current file path relative to the git project root local file_path = vim.fn.systemlist('git ls-files --full-name ' .. vim.fn.expand '%')[1] if not file_path or file_path == '' then print 'File not tracked by git.' return end - -- Get remote URL and clean it up (handles HTTPS and SSH) local remote = vim.fn.system('git config --get remote.origin.url'):gsub('\n', ''):gsub('%.git$', '') if remote:match '^git@' then remote = remote:gsub(':', '/'):gsub('git@', 'https://') end - -- Get current branch local branch = vim.fn.system('git rev-parse --abbrev-ref HEAD'):gsub('\n', '') - -- Get line numbers (handles single line or visual selection) local line_start = vim.fn.line 'v' local line_end = vim.fn.line '.' if line_start > line_end then @@ -44,11 +57,8 @@ M.open_github = function() line_anchor = 'L' .. line_start .. '-L' .. line_end end - -- Build and open the URL local url = string.format('%s/blob/%s/%s#%s', remote, branch, file_path, line_anchor) - - -- Linux only: using xdg-open in the background to avoid freezing Neovim - vim.fn.jobstart({ 'xdg-open', url }, { detach = true }) + open_url(url) print 'Opened in GitHub' end diff --git a/lua/plugins/kickstart/options.lua b/lua/plugins/kickstart/options.lua index e0b5ea83..533aacba 100644 --- a/lua/plugins/kickstart/options.lua +++ b/lua/plugins/kickstart/options.lua @@ -4,17 +4,16 @@ Purpose Sets buffer-agnostic Neovim options (`vim.o` / `vim.opt`): editing feel, - UI chrome, search, splits, and persistence (e.g. undofile). + UI chrome, search, splits, line numbers, and persistence (e.g. undofile). Rationale - Centralizing options keeps behavior predictable and documents defaults in - one place. Clipboard is scheduled after UI enter to avoid slowing startup. + Centralizing options keeps behavior predictable. Line numbers use `vim.opt` + only (no duplicate `vim.o.number`). Clipboard is scheduled after UI enter to + avoid slowing startup. See `:help vim.o`, `:help option-list`, `:help 'clipboard'`. ]] -vim.o.number = true - vim.o.mouse = 'a' vim.o.showmode = false diff --git a/lua/plugins/kickstart/plugins/conform.lua b/lua/plugins/kickstart/plugins/conform.lua index a3ef7e4c..b6a7b61e 100644 --- a/lua/plugins/kickstart/plugins/conform.lua +++ b/lua/plugins/kickstart/plugins/conform.lua @@ -31,27 +31,9 @@ return { ---@type conform.setupOpts opts = { notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { - c = true, - cpp = true, - typescript = true, - typescriptreact = true, - javascript = true, - javascriptreact = true, - python = true, - sql = true, - json = true, - } - if disable_filetypes[vim.bo[bufnr].filetype] then - return nil - else - return nil - end - end, + -- Explicit: no format-on-save (use `f` manually). Previously a + -- `format_on_save` function always returned nil with dead branch logic. + format_on_save = false, default_format_opts = { lsp_format = 'fallback', -- Use external formatters if configured below, otherwise use LSP formatting. Set to `false` to disable LSP formatting entirely. }, diff --git a/lua/plugins/kickstart/plugins/lsp.lua b/lua/plugins/kickstart/plugins/lsp.lua index 94c9bd68..73faf10a 100644 --- a/lua/plugins/kickstart/plugins/lsp.lua +++ b/lua/plugins/kickstart/plugins/lsp.lua @@ -41,35 +41,8 @@ return { { 'j-hui/fidget.nvim', opts = {} }, }, config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer + -- LspAttach: buffer-local LSP maps and optional semantic highlight / inlay hints. + -- See :help LspAttach, :help lsp-vs-treesitter vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), callback = function(event) @@ -172,21 +145,14 @@ return { -- -- This may be unwanted, since they displace some of your code if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then - map('th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') + -- `th` is used in keymaps.lua for terminal horizontal split. + map('ti', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle [I]nlay hints') end end, }) - - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. local capabilities = require('blink.cmp').get_lsp_capabilities() - -- Enable the following language servers - -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. - -- See `:help lsp-config` for information about keys and how to configure ---@type table local servers = { clangd = {}, @@ -376,14 +342,6 @@ return { }, }, } - -- - -- -- - -- -- FORCE GOPLS SETUP - -- -- - -- local gopls_config = servers.gopls - -- gopls_config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, gopls_config.capabilities or {}) - -- require('lspconfig').gopls.setup(gopls_config) - -- -- Ensure the servers and tools above are installed -- diff --git a/lua/plugins/kickstart/plugins/neotest_golang.lua b/lua/plugins/kickstart/plugins/neotest_golang.lua deleted file mode 100644 index 23db821f..00000000 --- a/lua/plugins/kickstart/plugins/neotest_golang.lua +++ /dev/null @@ -1,21 +0,0 @@ ---[[ - Path: lua/plugins/kickstart/plugins/neotest_golang.lua - Module: plugins.kickstart.plugins.neotest_golang - - Purpose - Lazy spec for neotest-golang: Neotest adapter for Go tests (table-driven, - subtests) when you wire Neotest core elsewhere. - - Rationale - Declared as a standalone plugin entry so enabling `nvim-neotest/neotest` - later only requires adding the core plugin + runners; this stays inert until then. - - See https://github.com/nvim-neotest/neotest and adapter README. -]] - ----@type LazySpec -return { -{ - 'fredrikaverpil/neotest-golang', -}, -} diff --git a/lua/plugins/kickstart/plugins/spec.lua b/lua/plugins/kickstart/plugins/spec.lua index 810be8e7..3767e2b9 100644 --- a/lua/plugins/kickstart/plugins/spec.lua +++ b/lua/plugins/kickstart/plugins/spec.lua @@ -42,7 +42,7 @@ local mods = { 'plugins.kickstart.plugins.mini', 'plugins.kickstart.plugins.treesitter', 'plugins.kickstart.plugins.vim_helm', - 'plugins.kickstart.plugins.neotest_golang', + 'plugins.kickstart.plugins.toggleterm', 'plugins.kickstart.plugins.mini_icons', 'plugins.kickstart.plugins.debug', 'plugins.kickstart.plugins.indent_line', diff --git a/lua/plugins/kickstart/plugins/toggleterm.lua b/lua/plugins/kickstart/plugins/toggleterm.lua new file mode 100644 index 00000000..1edfc246 --- /dev/null +++ b/lua/plugins/kickstart/plugins/toggleterm.lua @@ -0,0 +1,26 @@ +--[[ + Path: lua/plugins/kickstart/plugins/toggleterm.lua + Module: plugins.kickstart.plugins.toggleterm + + Purpose + Lazy spec for akinsho/toggleterm.nvim: floating terminal and the `:ToggleTerm` + command used by `tf` in `plugins.kickstart.keymaps`. + + Rationale + Keymaps referenced ToggleTerm without a plugin; this wires the dependency. + Floating keeps the editor context visible; change `direction` if you prefer split. + + See https://github.com/akinsho/toggleterm.nvim +]] + +---@type LazySpec +return { + { + 'akinsho/toggleterm.nvim', + version = '*', + opts = { + direction = 'float', + float_opts = { border = 'rounded' }, + }, + }, +} diff --git a/lua/plugins/kickstart/plugins/treesitter.lua b/lua/plugins/kickstart/plugins/treesitter.lua index fecd2506..92fc4972 100644 --- a/lua/plugins/kickstart/plugins/treesitter.lua +++ b/lua/plugins/kickstart/plugins/treesitter.lua @@ -45,7 +45,6 @@ return { 'css', 'helm', 'dockerfile', - 'bash', 'yaml', 'sql', 'hcl', diff --git a/lua/plugins/kickstart/plugins/which_key.lua b/lua/plugins/kickstart/plugins/which_key.lua index 38c43640..6e42b211 100644 --- a/lua/plugins/kickstart/plugins/which_key.lua +++ b/lua/plugins/kickstart/plugins/which_key.lua @@ -30,6 +30,7 @@ return { spec = { { 's', group = '[S]earch', mode = { 'n', 'v' } }, { 't', group = '[T]oggle' }, + { 'ti', desc = 'LSP inlay hints', mode = { 'n' } }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, -- Enable gitsigns recommended keymaps first { 'gr', group = 'LSP Actions', mode = { 'n' } }, },