low hanging fixes
This commit is contained in:
parent
6d7ac09a9e
commit
f6a12c9a9f
|
|
@ -10,29 +10,42 @@
|
|||
Small, focused utility used by `plugins.kickstart.keymaps` (`<leader>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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 `<leader>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.
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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('<leader>th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints')
|
||||
-- `<leader>th` is used in keymaps.lua for terminal horizontal split.
|
||||
map('<leader>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<string, vim.lsp.Config>
|
||||
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
|
||||
--
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
},
|
||||
}
|
||||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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 `<leader>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' },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -45,7 +45,6 @@ return {
|
|||
'css',
|
||||
'helm',
|
||||
'dockerfile',
|
||||
'bash',
|
||||
'yaml',
|
||||
'sql',
|
||||
'hcl',
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ return {
|
|||
spec = {
|
||||
{ '<leader>s', group = '[S]earch', mode = { 'n', 'v' } },
|
||||
{ '<leader>t', group = '[T]oggle' },
|
||||
{ '<leader>ti', desc = 'LSP inlay hints', mode = { 'n' } },
|
||||
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, -- Enable gitsigns recommended keymaps first
|
||||
{ 'gr', group = 'LSP Actions', mode = { 'n' } },
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue