Compare commits

...

2 commits

Author SHA1 Message Date
cdeb64a7e4
nvim: mini + tree-sitter setup 2024-11-07 00:23:55 +01:00
f3d1d92840
nvim: add bufremove 2024-11-06 20:03:42 +01:00
2 changed files with 182 additions and 118 deletions

View file

@ -25,18 +25,39 @@
nodePackages.typescript-language-server nodePackages.typescript-language-server
nodePackages.bash-language-server nodePackages.bash-language-server
rust-analyzer rust-analyzer
rustfmt
shellcheck shellcheck
shfmt shfmt
stylua stylua
tree-sitter tree-sitter
tree-sitter-grammars.tree-sitter-bash tree-sitter-grammars.tree-sitter-bash
tree-sitter-grammars.tree-sitter-yaml tree-sitter-grammars.tree-sitter-c
tree-sitter-grammars.tree-sitter-comment
tree-sitter-grammars.tree-sitter-css
tree-sitter-grammars.tree-sitter-cue
tree-sitter-grammars.tree-sitter-fish
tree-sitter-grammars.tree-sitter-gdscript
tree-sitter-grammars.tree-sitter-go tree-sitter-grammars.tree-sitter-go
tree-sitter-grammars.tree-sitter-markdown tree-sitter-grammars.tree-sitter-gomod
tree-sitter-grammars.tree-sitter-lua tree-sitter-grammars.tree-sitter-hcl
tree-sitter-grammars.tree-sitter-html tree-sitter-grammars.tree-sitter-html
tree-sitter-grammars.tree-sitter-vim tree-sitter-grammars.tree-sitter-javascript
tree-sitter-grammars.tree-sitter-json
tree-sitter-grammars.tree-sitter-lua
tree-sitter-grammars.tree-sitter-markdown
tree-sitter-grammars.tree-sitter-nix tree-sitter-grammars.tree-sitter-nix
tree-sitter-grammars.tree-sitter-proto
tree-sitter-grammars.tree-sitter-rego
tree-sitter-grammars.tree-sitter-rust
tree-sitter-grammars.tree-sitter-scss
tree-sitter-grammars.tree-sitter-sql
tree-sitter-grammars.tree-sitter-svelte
tree-sitter-grammars.tree-sitter-toml
tree-sitter-grammars.tree-sitter-tsx
tree-sitter-grammars.tree-sitter-typescript
tree-sitter-grammars.tree-sitter-vim
tree-sitter-grammars.tree-sitter-yaml
tree-sitter-grammars.tree-sitter-zig
vscode-langservers-extracted vscode-langservers-extracted
]; ];
@ -45,6 +66,7 @@
go-nvim go-nvim
rustaceanvim rustaceanvim
targets-vim targets-vim
ts-comments-nvim
{ {
plugin = pkgs.vimUtils.buildVimPlugin { plugin = pkgs.vimUtils.buildVimPlugin {
@ -85,12 +107,26 @@
} }
{ {
plugin = nvim-treesitter.withAllGrammars; # Treesitter plugin = nvim-treesitter-context;
type = "lua";
config = ''
vim.keymap.set('n', '<space>ut', "<cmd>TSContextToggle<cr>", {noremap = true, silent = true, desc = "TS Context"})
'';
}
{
plugin = nvim-treesitter.withAllGrammars;
type = "lua"; type = "lua";
config = '' config = ''
require'nvim-treesitter.configs'.setup { require'nvim-treesitter.configs'.setup {
highlight = { enable = true, }, highlight = { enable = true, },
indent = { enable = true }, indent = { enable = true },
textobjects = {
select = {
enable = true,
lookahead = true,
},
},
} }
''; '';
} }

View file

@ -1,128 +1,156 @@
local opts = function(label) local opts = function(label)
return {noremap = true, silent = true, desc = label} return { noremap = true, silent = true, desc = label }
end end
require('mini.ai').setup() require('mini.ai').setup()
require('mini.align').setup() require('mini.align').setup()
require('mini.bracketed').setup() require('mini.bracketed').setup()
require('mini.completion').setup() require('mini.comment').setup()
require('mini.diff').setup() require('mini.completion').setup()
require('mini.extra').setup() require('mini.diff').setup()
require('mini.icons').setup() require('mini.extra').setup()
require('mini.jump').setup() require('mini.icons').setup()
require('mini.surround').setup() require('mini.jump').setup()
require('mini.splitjoin').setup() require('mini.surround').setup()
require('mini.splitjoin').setup()
require('mini.trailspace').setup()
require('mini.files').setup() local bufremove = require('mini.bufremove')
local oil_style = function() bufremove.setup()
if not MiniFiles.close() then vim.keymap.set('n', '<space>bd', bufremove.delete, opts("Delete"))
MiniFiles.open(vim.api.nvim_buf_get_name(0))
MiniFiles.reveal_cwd()
end
end
vim.keymap.set('n', '-', oil_style, opts("File Explorer"));
local hipatterns = require('mini.hipatterns') require('mini.cursorword').setup({
hipatterns.setup({ -- highlight strings and colors delay = 800
highlighters = { })
-- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE'
fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' },
hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' },
todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' },
note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' },
-- Highlight hex color strings (`#rrggbb`) using that color local hipatterns = require('mini.hipatterns')
hex_color = hipatterns.gen_highlighter.hex_color(), hipatterns.setup({ -- highlight strings and colors
} highlighters = {
}) -- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE'
fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' },
hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' },
todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' },
note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' },
require('mini.jump2d').setup({ -- Highlight hex color strings (`#rrggbb`) using that color
mappings = { hex_color = hipatterns.gen_highlighter.hex_color(),
start_jumping = 'gw' }
} })
})
require('mini.pick').setup({ local indentscope = require('mini.indentscope')
mappings = { indentscope.setup({
move_down = '<tab>' draw = {
}, delay = 10,
options = { animation = indentscope.gen_animation.none(),
use_cache = true },
} symbol = '',
}) })
MiniPick.registry.files_root = function(local_opts)
local root_patterns = { ".jj", ".git" } require('mini.jump2d').setup({
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1]) mappings = {
local opts = { source = { cwd = root_dir, tool = "ripgrep"} } start_jumping = 'gw'
local_opts.cwd = root_dir }
local_opts.tool = "rg" })
return MiniPick.builtin.files(local_opts, opts)
end require('mini.pick').setup({
MiniPick.registry.grep_live_root = function(local_opts) mappings = {
local root_patterns = { ".jj", ".git" } move_down = '<tab>'
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1]) },
local opts = { source = { cwd = root_dir } } options = {
local_opts.cwd = root_dir use_cache = true
return MiniPick.builtin.grep_live(local_opts, opts) }
end })
vim.keymap.set('n', '<space>/', "<cmd>Pick grep_live_root<cr>", opts("Live Grep")) MiniPick.registry.files_root = function(local_opts)
vim.keymap.set('n', '<space>F', "<cmd>Pick files<cr>", opts("Find Files in CWD")) local root_patterns = { ".jj", ".git" }
vim.keymap.set('n', '<space>ff', "<cmd>Pick files_root<cr>", opts("Find Files")) local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
vim.keymap.set('n', '<space>fr', "<cmd>Pick oldfiles<cr>", opts("Recent Files")) local_opts.cwd = root_dir
vim.keymap.set('n', '<space>b', "<cmd>Pick buffers<cr>", opts("Buffers")) local_opts.tool = "rg"
vim.keymap.set('n', '<space>d', "<cmd>Pick diagnostics<cr>", opts("Diagnostics")) return MiniPick.builtin.files(local_opts, { source = { cwd = root_dir, tool = "ripgrep" } })
vim.keymap.set('n', '<tab>', "<cmd>Pick buffers include_current=false<cr>", opts("Buffers")) end
vim.keymap.set('n', "<space>'", "<cmd>Pick resume<cr>", opts("Last Picker")) MiniPick.registry.grep_live_root = function(local_opts)
vim.keymap.set('n', "<space>g", "<cmd>Pick git_commits<cr>", opts("Git Commits")) local root_patterns = { ".jj", ".git" }
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
local_opts.cwd = root_dir
return MiniPick.builtin.grep_live(local_opts, { source = { cwd = root_dir } })
end
vim.keymap.set('n', '<space>/', "<cmd>Pick grep_live_root<cr>", opts("Live Grep"))
vim.keymap.set('n', '<space>fF', "<cmd>Pick files<cr>", opts("FindCWD"))
vim.keymap.set('n', '<space>ff', "<cmd>Pick files_root<cr>", opts("Find"))
vim.keymap.set('n', '<space>fr', "<cmd>Pick oldfiles<cr>", opts("Recent"))
vim.keymap.set('n', '<space>bb', "<cmd>Pick buffers<cr>", opts("Switch"))
vim.keymap.set('n', '<space>d', "<cmd>Pick diagnostics<cr>", opts("Diagnostics"))
vim.keymap.set('n', '<tab>', "<cmd>Pick buffers include_current=false<cr>", opts("Buffers"))
local miniclue = require('mini.clue') local miniclue = require('mini.clue')
miniclue.setup({ -- cute prompts about bindings miniclue.setup({ -- cute prompts about bindings
triggers = { triggers = {
{ mode = 'n', keys = '<Leader>' }, { mode = 'n', keys = '<Leader>' },
{ mode = 'x', keys = '<Leader>' }, { mode = 'x', keys = '<Leader>' },
{ mode = 'n', keys = '<space>' }, { mode = 'n', keys = '<space>' },
{ mode = 'x', keys = '<space>' }, { mode = 'x', keys = '<space>' },
-- Built-in completion -- Built-in completion
{ mode = 'i', keys = '<C-x>' }, { mode = 'i', keys = '<C-x>' },
-- `g` key -- `g` key
{ mode = 'n', keys = 'g' }, { mode = 'n', keys = 'g' },
{ mode = 'x', keys = 'g' }, { mode = 'x', keys = 'g' },
-- Marks -- Marks
{ mode = 'n', keys = "'" }, { mode = 'n', keys = "'" },
{ mode = 'n', keys = '`' }, { mode = 'n', keys = '`' },
{ mode = 'x', keys = "'" }, { mode = 'x', keys = "'" },
{ mode = 'x', keys = '`' }, { mode = 'x', keys = '`' },
-- Registers -- Registers
{ mode = 'n', keys = '"' }, { mode = 'n', keys = '"' },
{ mode = 'x', keys = '"' }, { mode = 'x', keys = '"' },
{ mode = 'i', keys = '<C-r>' }, { mode = 'i', keys = '<C-r>' },
{ mode = 'c', keys = '<C-r>' }, { mode = 'c', keys = '<C-r>' },
-- Window commands -- Window commands
{ mode = 'n', keys = '<C-w>' }, { mode = 'n', keys = '<C-w>' },
-- `z` key -- `z` key
{ mode = 'n', keys = 'z' }, { mode = 'n', keys = 'z' },
{ mode = 'x', keys = 'z' }, { mode = 'x', keys = 'z' },
-- Bracketed -- Bracketed
{ mode = 'n', keys = '[' }, { mode = 'n', keys = '[' },
{ mode = 'n', keys = ']' }, { mode = 'n', keys = ']' },
}, },
clues = { clues = {
miniclue.gen_clues.builtin_completion(), miniclue.gen_clues.builtin_completion(),
miniclue.gen_clues.g(), miniclue.gen_clues.g(),
miniclue.gen_clues.marks(), miniclue.gen_clues.marks(),
miniclue.gen_clues.registers(), miniclue.gen_clues.registers(),
miniclue.gen_clues.windows(), miniclue.gen_clues.windows(),
miniclue.gen_clues.z(), miniclue.gen_clues.z(),
}, },
window = { window = {
delay = 15, delay = 15,
} }
}) })
local notify_win_config = function()
local has_statusline = vim.o.laststatus > 0
local pad = vim.o.cmdheight + (has_statusline and 1 or 0)
return { anchor = 'SE', border = 'rounded', col = vim.o.columns, row = vim.o.lines - pad }
end
require('mini.notify').setup({
window = {
config = notify_win_config,
winblend = 0,
},
})
require('mini.starter').setup({
header =
[[ ______ _
(_____ \ _ (_)
_____) )___| |_ ____ ____ _ ____
| ____/ _ | _)/ _ |/ _ | |/ _ |
| | ( ( | | |_( ( | ( ( | | ( ( | |
|_| \_||_|\___)_||_|\_|| |_|\_||_|
(_____|]]
})