Compare commits

...

5 commits

7 changed files with 341 additions and 319 deletions

View file

@ -5,6 +5,9 @@
...
}:
{
imports = [
./treesitter.nix
];
programs.man.generateCaches = false;
@ -39,35 +42,6 @@
shellcheck
shfmt
stylua
tree-sitter
tree-sitter-grammars.tree-sitter-bash
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-gomod
tree-sitter-grammars.tree-sitter-hcl
tree-sitter-grammars.tree-sitter-html
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-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
];
@ -77,6 +51,27 @@
targets-vim
ts-comments-nvim
{
plugin = blink-cmp;
type = "lua";
config = ''
require'blink-cmp'.setup({
keymap = 'super-tab',
windows = {
autocomplete = {
border = 'none',
},
documentation = {
border = 'rounded',
},
signature_help = {
border = 'rounded',
},
},
})
'';
}
{
plugin = codeium-nvim;
type = "lua";
@ -141,67 +136,6 @@
'';
}
{
plugin = nvim-treesitter-context;
type = "lua";
config = ''
require'treesitter-context'.setup{
enable = false,
}
vim.keymap.set('n', '<space>ut', "<cmd>TSContextToggle<cr>", {noremap = true, silent = true, desc = "TS Context"})
'';
}
{
plugin = nvim-treesitter.withAllGrammars;
type = "lua";
config = ''
require'nvim-treesitter.configs'.setup {
highlight = { enable = true, },
indent = { enable = true },
textobjects = {
select = {
enable = true,
lookahead = true,
},
},
}
'';
}
{
plugin = pkgs.vimUtils.buildVimPlugin {
name = "nvim-tree-pairs"; # make % match in TS
src = pkgs.fetchFromGitHub {
owner = "yorickpeterse";
repo = "nvim-tree-pairs";
rev = "e7f7b6cc28dda6f3fa271ce63b0d371d5b7641da";
hash = "sha256-fb4EsrWAbm8+dWAhiirCPuR44MEg+KYb9hZOIuEuT24=";
};
};
type = "lua";
config = "require('tree-pairs').setup()";
}
{
plugin = nvim-treesitter-textobjects;
type = "lua";
config = ''
require'nvim-treesitter.configs'.setup {
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<M-o>",
scope_incremental = "<M-O>",
node_incremental = "<M-o>",
node_decremental = "<M-i>",
},
},
}
'';
}
{
plugin = mini-nvim;
type = "lua";

View file

@ -76,6 +76,16 @@ local colors = {
-- dialog_bg = hsl(216, 25, 20),
-- selection = hsl(216, 25, 33),
selection = hsl(213, 60, 40),
cmp_bg = hsl(218, 30, 13),
cmp_fg = hsl(218, 30, 60),
cmp_selected_bg = hsl(218, 30, 25),
cmp_selected_fg = hsl(218, 50, 80),
doc_bg = hsl(220, 80, 10),
doc_fg = hsl(200, 30, 60),
suggestion = hsl(180, 55, 40),
},
}
@ -158,6 +168,20 @@ local theme = {
MiniClueDescGroup = { bg = c.background, fg = c.foreground, italic = true },
MiniClueSeparator = { link = "NormalFloat" },
BlinkCmpMenu = { bg = c.cmp_bg, fg = c.cmp_fg },
BlinkCmpMenuSelection = { bg = c.cmp_selected_bg, fg = c.cmp_selected_fg, reverse = false },
BlinkCmpMenuBorder = { bg = c.cmp_bg, fg = c.cmp_fg },
BlinkCmpLabel = { link = 'BlinkCmpMenu' },
BlinkCmpLabelMatch = { link = 'BlinkCmpMenu', underline = true },
BlinkCmpDoc = { bg = c.doc_bg, fg = c.foreground },
BlinkCmpDocBorder = { bg = c.doc_bg, fg = c.doc_fg },
BlinkCmpDocDetail = { link = 'BlinkCmpDoc' },
BlinkCmpSignatureHelp = { link = 'BlinkCmpDoc' },
BlinkCmpSignatureHelpBorder = { link = 'BlinkCmpDocBorder' },
NeoCodeiumSuggestion = { fg = c.suggestion , bold = true, italic = true },
NoiceMini = { fg = c.foreground, italic = true },
TelescopeNormal = { fg = c.foreground, bg = c.background },

View file

@ -1,4 +1,4 @@
vim.g.mapleader = "<space>"
vim.g.mapleader = ' '
vim.g.maplocalleader = ","
-- UI
@ -21,6 +21,7 @@ function GetIndicators()
local error_string = errors > 0 and "%#DiagnosticError# " .. errors .. " " or " "
return warn_string .. error_string
end
vim.opt.rulerformat = "%40(%=%{%v:lua.GetIndicators()%}%#Label#│ %t %)"
-- Search
@ -52,17 +53,16 @@ vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
--
vim.o.autochdir = true
vim.o.cia = 'kind,abbr,menu'
vim.o.fillchars = "stl: ,stlnc: ,eob:░,vert:│"
vim.o.icm = "split"
vim.o.list = false
vim.o.scrolloff = 7
vim.o.splitkeep = "screen"
vim.o.updatetime = 50
vim.o.timeout = true
vim.o.timeoutlen = 10
vim.o.icm = "split"
vim.o.cia = 'kind,abbr,menu'
vim.o.showmode = false
vim.o.splitkeep = "screen"
vim.o.timeoutlen = 10
vim.o.timeout = true
vim.o.updatetime = 50
-- Use rg
@ -95,8 +95,44 @@ vim.keymap.set({ "i", "s" }, "<Tab>", function()
end
end, { expr = true })
vim.keymap.set({ "n" }, "<c-/>", "gcc", { remap = true })
vim.keymap.set({ "v" }, "<c-/>", "gc", { remap = true })
vim.keymap.set({ "n" }, "<c-_>", "gcc", { remap = true })
vim.keymap.set({ "v" }, "<c-_>", "gc", { remap = true })
-- Keymap
local opts = function(label)
return { noremap = true, silent = true, desc = label }
end
-- Comments
vim.keymap.set("n", "<c-/>", "gcc", { remap = true })
vim.keymap.set("v", "<c-/>", "gc", { remap = true })
vim.keymap.set("n", "<c-_>", "gcc", { remap = true })
vim.keymap.set("v", "<c-_>", "gc", { remap = true })
vim.keymap.set({ "n", "v" }, "<Leader>a", vim.lsp.buf.code_action, { remap = true, desc = "Code action" })
vim.keymap.set("n", "<Leader>af", function()
vim.lsp.buf.format({ async = true })
end, opts("Format Buffer"))
vim.keymap.set('n', '<Leader>b', "<cmd>Pick buffers<cr>", opts("Open buffer picker"))
vim.keymap.set('n', '<Leader>/', "<cmd>Pick grep_live_root<cr>", opts("Search workspace files"))
vim.keymap.set('n', '<Leader>d', "<cmd>Pick diagnostic<cr>", opts("Open diagnostics picker"))
vim.keymap.set("n", "<Leader>D", vim.diagnostic.setloclist, { desc = "Diagnostics to location list" })
vim.keymap.set("n", "<Leader>r", vim.lsp.buf.rename, opts("Rename Symbol"))
vim.keymap.set('n', '<Leader>F', "<cmd>Pick files<cr>", opts("Open file picker CWD"))
vim.keymap.set('n', '<Leader>f', "<cmd>Pick files_root<cr>", opts("Open file picker"))
vim.keymap.set('n', '<Leader>g', "<cmd>Pick oldfiles<cr>", opts("Open file picker history"))
vim.keymap.set("n", '<Leader>k', vim.lsp.buf.hover, opts("Show docs for item under cursor"))
vim.keymap.set('n', '<Leader>q', require('mini.bufremove').delete, opts("Delete buffer"))
vim.keymap.set('n', '<Leader>s', "<cmd>Pick lsp scope='document_symbol'<cr>", opts("Open symbol picker"))
vim.keymap.set('n', '<Leader>S', "<cmd>Pick lsp scope='workspace_symbol'<cr>", opts("Open workspace symbol picker"))
vim.keymap.set("n", "<Leader>ws", "<C-w>s", opts("Horizontal split"))
vim.keymap.set("n", "<Leader>wv", "<C-w>v", opts("Vertical split"))
vim.keymap.set('n', '<tab>', "<cmd>Pick buffers include_current=false<cr>", opts("Buffers"))
vim.keymap.set("n", "zz", "zt", { remap = true })
vim.keymap.set({ "n", "v" }, "<Leader>y", '"+y', opts("Yank to clipboard"))
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts("Declaration"))
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts("Definition"))
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts("Implementation"))
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts("Buffer References"))
vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, opts("Type Definition"))
vim.keymap.set({"n", "i"}, "<M-k>", vim.lsp.buf.signature_help, opts("Signature Help"))
vim.keymap.set({ "n", "v" }, "<Leader>aa", vim.lsp.buf.code_action, opts("Code Action"))

View file

@ -1,5 +1,3 @@
vim.keymap.set("n", "<space>d", vim.diagnostic.setloclist, { desc = "Add buffer diagnostics to the location list." })
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
@ -16,28 +14,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
if client.server_capabilities.codeLensProvider then
vim.lsp.codelens.refresh({ bufnr = bufnr })
end
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
vim.keymap.set("n", "gd", vim.lsp.buf.definition, {})
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, {})
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts("Declaration"))
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts("Definition"))
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts("Implementation"))
vim.keymap.set("n", "<M-k>", vim.lsp.buf.signature_help, opts("Signature Help"))
vim.keymap.set("i", "<M-k>", vim.lsp.buf.signature_help, opts("Signature Help"))
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts("Add Workspace Folder"))
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts("Remove Workspace Folder"))
vim.keymap.set("n", "<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts("List Workspace Folders"))
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, opts("Type Definition"))
vim.keymap.set("n", "<space>r", vim.lsp.buf.rename, opts("Rename Symbol"))
vim.keymap.set({ "n", "v" }, "<space>a", vim.lsp.buf.code_action, opts("Code Action"))
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts("Buffer References"))
vim.keymap.set("n", "<space>cf", function()
vim.lsp.buf.format({ async = true })
end, opts("Format Buffer"))
end,
})

View file

@ -1,9 +1,7 @@
local opts = function(label)
return { noremap = true, silent = true, desc = label }
end
require('mini.ai').setup()
require('mini.align').setup()
require('mini.bracketed').setup()
require('mini.bufremove').setup()
require('mini.comment').setup()
require('mini.diff').setup()
require('mini.extra').setup()
@ -13,52 +11,10 @@ require('mini.surround').setup()
require('mini.splitjoin').setup()
require('mini.trailspace').setup()
local bufremove = require('mini.bufremove')
bufremove.setup()
vim.keymap.set('n', '<space>bd', bufremove.delete, opts("Delete"))
require('mini.cursorword').setup({
delay = 800
})
require('mini.completion').setup({
window = {
info = { height = 25, width = 80, border = 'rounded' },
signature = { height = 25, width = 80, border = 'rounded' },
},
})
local imap_expr = function(lhs, rhs)
vim.keymap.set('i', lhs, rhs, { expr = true })
end
imap_expr('<Tab>', [[pumvisible() ? "\<C-n>" : "\<Tab>"]])
imap_expr('<S-Tab>', [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]])
local keycode = vim.keycode or function(x)
return vim.api.nvim_replace_termcodes(x, true, true, true)
end
local keys = {
['cr'] = keycode('<CR>'),
['ctrl-y'] = keycode('<C-y>'),
['ctrl-y_cr'] = keycode('<C-y><CR>'),
}
_G.cr_action = function()
if vim.fn.pumvisible() ~= 0 then
-- If popup is visible, confirm selected item or add new line otherwise
local item_selected = vim.fn.complete_info()['selected'] ~= -1
return item_selected and keys['ctrl-y'] or keys['ctrl-y_cr']
else
-- If popup is not visible, use plain `<CR>`. You might want to customize
-- according to other plugins. For example, to use 'mini.pairs', replace
-- next line with `return require('mini.pairs').cr()`
return keys['cr']
end
end
vim.keymap.set('i', '<CR>', 'v:lua._G.cr_action()', { expr = true })
local hipatterns = require('mini.hipatterns')
hipatterns.setup({
highlighters = {
@ -84,9 +40,29 @@ require('mini.jump2d').setup({
mappings = { start_jumping = 'gw' }
})
local picker_win_config = function()
local height = vim.o.lines - 8
local width = 80
return {
border = 'rounded',
anchor = 'NW',
height = height,
width = width,
row = 2,
col = math.floor((vim.o.columns - width) / 2),
}
end
require('mini.pick').setup({
mappings = { move_down = '<tab>' },
options = { use_cache = true }
mappings = {
move_down = '<tab>',
toggle_info = '<C-k>',
toggle_preview = '<C-p>',
},
options = { use_cache = true },
window = {
config = picker_win_config,
},
})
MiniPick.registry.files_root = function(local_opts)
local root_patterns = { ".jj", ".git" }
@ -101,13 +77,6 @@ MiniPick.registry.grep_live_root = function(local_opts)
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')
@ -157,7 +126,11 @@ miniclue.setup({ -- cute prompts about bindings
miniclue.gen_clues.z(),
},
window = {
delay = 15,
delay = 0,
config = {
border = 'rounded',
width = 'auto',
},
}
})

View file

@ -0,0 +1,79 @@
{
inputs,
lib,
pkgs,
...
}:
{
programs.neovim = {
extraPackages = with pkgs; [
tree-sitter
];
plugins = with pkgs.vimPlugins; [
ts-comments-nvim
nvim-ts-context-commentstring
{
plugin = nvim-treesitter-context;
type = "lua";
config = ''
require'treesitter-context'.setup{
enable = false,
}
vim.keymap.set('n', '<space>ut', "<cmd>TSContextToggle<cr>", {noremap = true, silent = true, desc = "TS Context"})
'';
}
{
plugin = nvim-treesitter.withAllGrammars;
type = "lua";
config = ''
require'nvim-treesitter.configs'.setup {
highlight = { enable = true, },
indent = { enable = true },
rainbow = { enable = true },
textobjects = {
select = {
enable = true,
lookahead = true,
},
},
}
'';
}
{
plugin = pkgs.vimUtils.buildVimPlugin {
name = "nvim-tree-pairs"; # make % match in TS
src = pkgs.fetchFromGitHub {
owner = "yorickpeterse";
repo = "nvim-tree-pairs";
rev = "e7f7b6cc28dda6f3fa271ce63b0d371d5b7641da";
hash = "sha256-fb4EsrWAbm8+dWAhiirCPuR44MEg+KYb9hZOIuEuT24=";
};
};
type = "lua";
config = "require('tree-pairs').setup()";
}
{
plugin = nvim-treesitter-textobjects;
type = "lua";
config = ''
require'nvim-treesitter.configs'.setup {
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<M-o>",
scope_incremental = "<M-O>",
node_incremental = "<M-o>",
node_decremental = "<M-i>",
},
},
}
'';
}
];
};
}

View file

@ -6,7 +6,7 @@
clock24 = true;
escapeTime = 500;
mouse = true;
shortcut = "o";
shortcut = "t";
extraConfig = ''
set -g allow-passthrough on
set -g default-terminal "tmux-256color"