Port hecate config: language servers, formatters, treesitter parsers, custom plugins
- init.lua: relativenumber, colorcolumn=120, expandtab=false, isfname @-@, [d/]d diagnostic navigation, <leader>e diagnostic float, hecate hostname - lsp.lua: add gopls, basedpyright (uv venv detection), ts_ls, nimls/gleam (conditional), rust-analyzer in mason_tools; gleam indentation autocmd - treesitter.lua: expand parsers (rust, go, js, ts, py, json, yaml, toml, gleam, nim) - format.lua: full conform config with all formatters and :Format range command - telescope.lua: add <C-p> git_files and <leader>pf prompted grep - custom/plugins/rust.lua: rustaceanvim ^6 - custom/plugins/trouble.lua: trouble.nvim with standard keybindings - custom/plugins/gitsigns.lua: enable whipsmart gitsigns extended keymaps
This commit is contained in:
parent
761f4a131e
commit
9ab7b3b2d3
9
init.lua
9
init.lua
|
|
@ -53,6 +53,8 @@ do
|
|||
-- Vera specific settings
|
||||
elseif hostname == 'tau' then
|
||||
-- tau specific settings
|
||||
elseif hostname == 'hecate' then
|
||||
-- hecate specific settings
|
||||
end
|
||||
|
||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||
|
|
@ -61,6 +63,7 @@ do
|
|||
-- [[ Setting options ]]
|
||||
-- See `:help vim.o`
|
||||
vim.o.number = true
|
||||
vim.o.relativenumber = true
|
||||
vim.o.mouse = 'a'
|
||||
vim.o.showmode = false
|
||||
vim.schedule(function() vim.o.clipboard = 'unnamedplus' end)
|
||||
|
|
@ -79,6 +82,9 @@ do
|
|||
vim.o.cursorline = true
|
||||
vim.o.scrolloff = 10
|
||||
vim.o.confirm = true
|
||||
vim.o.colorcolumn = '120'
|
||||
vim.o.expandtab = false
|
||||
vim.opt.isfname:append '@-@'
|
||||
|
||||
-- [[ Basic Keymaps ]]
|
||||
-- See `:help vim.keymap.set()`
|
||||
|
|
@ -100,6 +106,9 @@ do
|
|||
}
|
||||
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
|
||||
vim.keymap.set('n', '[d', function() vim.diagnostic.jump { count = -1 } end, { desc = 'Go to previous [D]iagnostic' })
|
||||
vim.keymap.set('n', ']d', function() vim.diagnostic.jump { count = 1 } end, { desc = 'Go to next [D]iagnostic' })
|
||||
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
||||
|
||||
-- Split navigation
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
-- Enable extended gitsigns keymaps (hunk navigation, stage/reset, blame, diff, text object)
|
||||
require 'whipsmart.plugins.gitsigns'
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
-- Rust: rustaceanvim manages rust-analyzer (installed by Mason via lsp.lua)
|
||||
vim.pack.add { { src = 'https://github.com/mrcjkb/rustaceanvim', version = vim.version.range '^6' } }
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
vim.pack.add { 'https://github.com/folke/trouble.nvim' }
|
||||
require('trouble').setup {}
|
||||
|
||||
vim.keymap.set('n', '<leader>xx', '<cmd>Trouble diagnostics toggle<cr>', { desc = 'Diagnostics (Trouble)' })
|
||||
vim.keymap.set('n', '<leader>xX', '<cmd>Trouble diagnostics toggle filter.buf=0<cr>', { desc = 'Buffer Diagnostics (Trouble)' })
|
||||
vim.keymap.set('n', '<leader>cs', '<cmd>Trouble symbols toggle focus=false<cr>', { desc = 'Symbols (Trouble)' })
|
||||
vim.keymap.set('n', '<leader>cl', '<cmd>Trouble lsp toggle focus=false win.position=right<cr>', { desc = 'LSP Definitions/References (Trouble)' })
|
||||
vim.keymap.set('n', '<leader>xL', '<cmd>Trouble loclist toggle<cr>', { desc = 'Location List (Trouble)' })
|
||||
vim.keymap.set('n', '<leader>xQ', '<cmd>Trouble qflist toggle<cr>', { desc = 'Quickfix List (Trouble)' })
|
||||
|
|
@ -7,18 +7,35 @@ local function gh(repo) return 'https://github.com/' .. repo end
|
|||
|
||||
vim.pack.add { gh 'stevearc/conform.nvim' }
|
||||
|
||||
-- Add filetypes here to enable format-on-save for them, e.g. lua = true
|
||||
local fmt_on_save_fts = {}
|
||||
|
||||
require('conform').setup {
|
||||
notify_on_error = false,
|
||||
format_on_save = function(bufnr)
|
||||
if fmt_on_save_fts[vim.bo[bufnr].filetype] then
|
||||
return { timeout_ms = 500, lsp_format = 'fallback' }
|
||||
end
|
||||
end,
|
||||
default_format_opts = { lsp_format = 'fallback' },
|
||||
formatters_by_ft = {},
|
||||
format_on_save = { timeout_ms = 500, lsp_format = 'fallback' },
|
||||
formatters_by_ft = {
|
||||
lua = { 'stylua' },
|
||||
python = { 'ruff_format', 'ruff_organize_imports' },
|
||||
rust = { 'rustfmt' },
|
||||
go = { 'goimports', 'gofmt' },
|
||||
javascript = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
typescript = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
javascriptreact = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
typescriptreact = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
json = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
html = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
css = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
markdown = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
yaml = { 'prettierd', 'prettier', stop_after_first = true },
|
||||
},
|
||||
}
|
||||
|
||||
vim.keymap.set({ 'n', 'v' }, '<leader>f', function() require('conform').format { async = true } end, { desc = '[F]ormat buffer' })
|
||||
vim.api.nvim_create_user_command('Format', function(args)
|
||||
local range = nil
|
||||
if args.count ~= -1 then
|
||||
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
|
||||
range = { start = { args.line1, 0 }, ['end'] = { args.line2, end_line:len() } }
|
||||
end
|
||||
require('conform').format { async = true, lsp_format = 'fallback', range = range }
|
||||
end, { range = true })
|
||||
|
||||
vim.keymap.set({ 'n', 'v' }, '<leader>cf', function()
|
||||
require('conform').format { async = false, lsp_format = 'fallback', timeout_ms = 1000 }
|
||||
end, { desc = '[C]ode [F]ormat file or range' })
|
||||
|
|
|
|||
|
|
@ -70,6 +70,32 @@ local servers = {
|
|||
end,
|
||||
settings = { Lua = { format = { enable = false } } },
|
||||
},
|
||||
gopls = {},
|
||||
basedpyright = {
|
||||
settings = {
|
||||
basedpyright = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
diagnosticMode = 'openFilesOnly',
|
||||
},
|
||||
},
|
||||
},
|
||||
before_init = function(_, config)
|
||||
local root_dir = config.root_dir
|
||||
if root_dir then
|
||||
local venv_path = root_dir .. '/.venv'
|
||||
if vim.fn.isdirectory(venv_path) == 1 then
|
||||
local python_path = venv_path .. '/bin/python'
|
||||
if vim.fn.filereadable(python_path) == 1 then
|
||||
config.settings.python = config.settings.python or {}
|
||||
config.settings.python.pythonPath = python_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
ts_ls = {},
|
||||
}
|
||||
|
||||
vim.pack.add {
|
||||
|
|
@ -82,6 +108,13 @@ vim.pack.add {
|
|||
local mason_tools = {
|
||||
'lua-language-server',
|
||||
'stylua',
|
||||
'gopls',
|
||||
'goimports',
|
||||
'basedpyright',
|
||||
'ruff',
|
||||
'typescript-language-server',
|
||||
'prettierd',
|
||||
'rust-analyzer', -- installed by Mason, managed by rustaceanvim (see custom/plugins/rust.lua)
|
||||
}
|
||||
|
||||
require('mason').setup {}
|
||||
|
|
@ -91,3 +124,26 @@ for name, server in pairs(servers) do
|
|||
vim.lsp.config(name, server)
|
||||
vim.lsp.enable(name)
|
||||
end
|
||||
|
||||
-- System-installed LSPs (not managed by Mason)
|
||||
if vim.fn.executable 'nimls' == 1 then
|
||||
vim.lsp.config('nimls', {})
|
||||
vim.lsp.enable 'nimls'
|
||||
end
|
||||
|
||||
if vim.fn.executable 'gleam' == 1 then
|
||||
vim.lsp.config('gleam', {})
|
||||
vim.lsp.enable 'gleam'
|
||||
end
|
||||
|
||||
-- Gleam indentation
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
group = vim.api.nvim_create_augroup('whipsmart-gleam-indent', { clear = true }),
|
||||
pattern = 'gleam',
|
||||
callback = function()
|
||||
vim.bo.shiftwidth = 2
|
||||
vim.bo.tabstop = 2
|
||||
vim.bo.softtabstop = 2
|
||||
vim.bo.expandtab = true
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -64,3 +64,7 @@ vim.keymap.set('n', '<leader>s/', function()
|
|||
end, { desc = '[S]earch [/] in Open Files' })
|
||||
|
||||
vim.keymap.set('n', '<leader>sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' })
|
||||
vim.keymap.set('n', '<C-p>', builtin.git_files, { desc = 'Search [G]it Files' })
|
||||
vim.keymap.set('n', '<leader>pf', function()
|
||||
builtin.grep_string { search = vim.fn.input 'Grep > ' }
|
||||
end, { desc = '[P]roject [F]ind (grep with input)' })
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ local function gh(repo) return 'https://github.com/' .. repo end
|
|||
|
||||
vim.pack.add { { src = gh 'nvim-treesitter/nvim-treesitter', version = 'main' } }
|
||||
|
||||
local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
|
||||
local parsers = {
|
||||
'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc',
|
||||
'rust', 'go', 'javascript', 'typescript', 'python', 'json', 'yaml', 'toml', 'gleam', 'nim',
|
||||
}
|
||||
require('nvim-treesitter').install(parsers)
|
||||
|
||||
local function treesitter_try_attach(buf, language)
|
||||
|
|
|
|||
Loading…
Reference in New Issue