mirror of
https://github.com/softinio/nix-config.git
synced 2025-10-18 19:16:41 -07:00
Add neovim config using nixvim
This commit is contained in:
parent
5151384820
commit
2708a86df9
18 changed files with 864 additions and 9 deletions
|
@ -6,6 +6,7 @@
|
|||
./git
|
||||
./jujutsu
|
||||
# ./kitty
|
||||
./nixvim
|
||||
./tmux
|
||||
./wezterm
|
||||
./vscode
|
||||
|
|
17
programs/nixvim/_plugins/avante.nix
Normal file
17
programs/nixvim/_plugins/avante.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins.avante = {
|
||||
enable = true;
|
||||
settings = {
|
||||
provider = "claude";
|
||||
providers = {
|
||||
claude = {
|
||||
model = "claude-sonnet-4-5-20250929";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
36
programs/nixvim/_plugins/conform.nix
Normal file
36
programs/nixvim/_plugins/conform.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins.conform-nvim = {
|
||||
enable = true;
|
||||
settings = {
|
||||
formatters_by_ft = {
|
||||
lua = [ "stylua" ];
|
||||
nix = [ "nixfmt" ];
|
||||
python = ''
|
||||
function(bufnr)
|
||||
if require("conform").get_formatter_info("ruff_format", bufnr).available then
|
||||
return { "ruff_fix", "ruff_format" }
|
||||
else
|
||||
return { "isort", "black", "flake8" }
|
||||
end
|
||||
end
|
||||
'';
|
||||
scala = [ "scalafmt" ];
|
||||
swift = [ "swift_format" ];
|
||||
"*" = [ "trim_whitespace" "trim_newlines" ];
|
||||
};
|
||||
format_on_save = ''
|
||||
function(bufnr)
|
||||
-- Disable with a global or buffer-local variable
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
return { timeout_ms = 500, lsp_fallback = true }
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
105
programs/nixvim/_plugins/default.nix
Normal file
105
programs/nixvim/_plugins/default.nix
Normal file
|
@ -0,0 +1,105 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./avante.nix
|
||||
./conform.nix
|
||||
./floaterm.nix
|
||||
./lsp.nix
|
||||
./lualine.nix
|
||||
./neo-tree.nix
|
||||
./telescope.nix
|
||||
./treesitter.nix
|
||||
];
|
||||
|
||||
# Global plugin configurations can go here
|
||||
programs.nixvim = {
|
||||
colorschemes.tokyonight = {
|
||||
enable = true;
|
||||
settings = {
|
||||
style = "night";
|
||||
on_colors.__raw = "function(colors) colors.bg = \"#000000\" end";
|
||||
};
|
||||
};
|
||||
|
||||
plugins = {
|
||||
# Lazy loading
|
||||
lz-n.enable = true;
|
||||
|
||||
web-devicons.enable = true;
|
||||
|
||||
gitsigns = {
|
||||
enable = true;
|
||||
settings.signs = {
|
||||
add.text = "+";
|
||||
change.text = "~";
|
||||
delete.text = "_";
|
||||
topdelete.text = "‾";
|
||||
changedelete.text = "~";
|
||||
};
|
||||
};
|
||||
|
||||
nvim-autopairs.enable = true;
|
||||
|
||||
colorizer = {
|
||||
enable = true;
|
||||
settings.user_default_options.names = false;
|
||||
};
|
||||
|
||||
copilot-vim.enable = true;
|
||||
|
||||
fidget.enable = true;
|
||||
|
||||
flash.enable = true;
|
||||
|
||||
img-clip = {
|
||||
enable = true;
|
||||
settings = {
|
||||
default = {
|
||||
embed_image_as_base64 = false;
|
||||
prompt_for_file_name = false;
|
||||
drag_and_drop = {
|
||||
insert_mode = true;
|
||||
};
|
||||
use_absolute_path = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
indent-blankline.enable = true;
|
||||
|
||||
markview.enable = true;
|
||||
|
||||
nui.enable = true;
|
||||
|
||||
oil = {
|
||||
enable = true;
|
||||
lazyLoad.settings.cmd = "Oil";
|
||||
};
|
||||
|
||||
snacks.enable = true;
|
||||
|
||||
todo-comments = {
|
||||
enable = true;
|
||||
keymaps.todoTelescope.key = "<leader>t";
|
||||
};
|
||||
|
||||
trim = {
|
||||
enable = true;
|
||||
settings = {
|
||||
highlight = true;
|
||||
ft_blocklist = [
|
||||
"checkhealth"
|
||||
"floaterm"
|
||||
"lspinfo"
|
||||
"neo-tree"
|
||||
"TelescopePrompt"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
trouble.enable = true;
|
||||
which-key.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
14
programs/nixvim/_plugins/floaterm.nix
Normal file
14
programs/nixvim/_plugins/floaterm.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.nixvim.plugins.floaterm = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
width = 0.8;
|
||||
height = 0.8;
|
||||
title = "";
|
||||
keymap_toggle = "<leader>,";
|
||||
};
|
||||
};
|
||||
}
|
61
programs/nixvim/_plugins/lsp.nix
Normal file
61
programs/nixvim/_plugins/lsp.nix
Normal file
|
@ -0,0 +1,61 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
programs.nixvim = {
|
||||
diagnostic.settings.virtual_text = true;
|
||||
|
||||
lsp = {
|
||||
inlayHints.enable = true;
|
||||
servers = {
|
||||
bashls.enable = true;
|
||||
html.enable = true;
|
||||
jqls.enable = true;
|
||||
jsonls.enable = true;
|
||||
lua_ls = {
|
||||
enable = true;
|
||||
settings.settings.diagnostics.globals = [ "vim" ];
|
||||
};
|
||||
marksman.enable = true;
|
||||
metals.enable = true;
|
||||
nil_ls.enable = true;
|
||||
nixd.enable = true;
|
||||
pyrefly.enable = true;
|
||||
rust_analyzer.enable = true;
|
||||
sourcekit.enable = true;
|
||||
ts_ls.enable = true;
|
||||
yamlls.enable = true;
|
||||
};
|
||||
|
||||
keymaps =
|
||||
lib.mapAttrsToList
|
||||
(
|
||||
key: props:
|
||||
{
|
||||
inherit key;
|
||||
options.silent = true;
|
||||
}
|
||||
// props
|
||||
)
|
||||
{
|
||||
"<leader>k".action.__raw = "function() vim.diagnostic.jump({ count=-1, float=true }) end";
|
||||
"<leader>j".action.__raw = "function() vim.diagnostic.jump({ count=1, float=true }) end";
|
||||
gd.lspBufAction = "definition";
|
||||
gD.lspBufAction = "references";
|
||||
gt.lspBufAction = "type_definition";
|
||||
gi.lspBufAction = "implementation";
|
||||
K.lspBufAction = "hover";
|
||||
"<F2>".lspBufAction = "rename";
|
||||
};
|
||||
};
|
||||
|
||||
plugins = {
|
||||
lsp-format = {
|
||||
enable = true;
|
||||
lspServersToEnable = "all";
|
||||
};
|
||||
|
||||
# Sane defaults for all servers
|
||||
lspconfig.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
49
programs/nixvim/_plugins/lualine.nix
Normal file
49
programs/nixvim/_plugins/lualine.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.nixvim.plugins.lualine = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
options.globalstatus = true;
|
||||
|
||||
sections = {
|
||||
lualine_a = [ "mode" ];
|
||||
lualine_b = [ "branch" ];
|
||||
lualine_c = [
|
||||
"filename"
|
||||
"diff"
|
||||
];
|
||||
|
||||
lualine_x = [
|
||||
"diagnostics"
|
||||
|
||||
{
|
||||
__unkeyed.__raw = ''
|
||||
function()
|
||||
local msg = ""
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
|
||||
local clients = vim.lsp.get_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end
|
||||
'';
|
||||
icon = "";
|
||||
color.fg = "#ffffff";
|
||||
}
|
||||
"encoding"
|
||||
"fileformat"
|
||||
"filetype"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
25
programs/nixvim/_plugins/neo-tree.nix
Normal file
25
programs/nixvim/_plugins/neo-tree.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.nixvim = {
|
||||
keymaps = [
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>m";
|
||||
action = ":Neotree action=focus reveal toggle<CR>";
|
||||
options.silent = true;
|
||||
}
|
||||
];
|
||||
|
||||
plugins.neo-tree = {
|
||||
enable = true;
|
||||
|
||||
closeIfLastWindow = true;
|
||||
window = {
|
||||
width = 30;
|
||||
autoExpandWidth = true;
|
||||
position = "right";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
55
programs/nixvim/_plugins/telescope.nix
Normal file
55
programs/nixvim/_plugins/telescope.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.nixvim = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
|
||||
extensions = {
|
||||
fzf-native.enable = true;
|
||||
ui-select.enable = true;
|
||||
undo.enable = true;
|
||||
};
|
||||
|
||||
keymaps = {
|
||||
"<leader>ff" = "find_files";
|
||||
"<leader>fg" = "live_grep";
|
||||
"<leader>b" = "buffers";
|
||||
"<leader>fh" = "help_tags";
|
||||
"<leader>fd" = "diagnostics";
|
||||
|
||||
"<C-p>" = "git_files";
|
||||
"<leader>p" = "oldfiles";
|
||||
"<C-f>" = "live_grep";
|
||||
};
|
||||
|
||||
settings.defaults = {
|
||||
file_ignore_patterns = [
|
||||
"^.git/"
|
||||
"^.mypy_cache/"
|
||||
"^__pycache__/"
|
||||
"^output/"
|
||||
"^data/"
|
||||
"%.ipynb"
|
||||
];
|
||||
set_env.COLORTERM = "truecolor";
|
||||
};
|
||||
};
|
||||
|
||||
keymaps = [
|
||||
{
|
||||
mode = "n";
|
||||
key = "<C-t>";
|
||||
action.__raw = ''
|
||||
function()
|
||||
require('telescope.builtin').live_grep({
|
||||
default_text="TODO",
|
||||
initial_mode="normal"
|
||||
})
|
||||
end
|
||||
'';
|
||||
options.silent = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
69
programs/nixvim/_plugins/treesitter.nix
Normal file
69
programs/nixvim/_plugins/treesitter.nix
Normal file
|
@ -0,0 +1,69 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.nixvim.plugins = {
|
||||
treesitter = {
|
||||
enable = true;
|
||||
|
||||
grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
|
||||
awk
|
||||
bash
|
||||
c
|
||||
cpp
|
||||
css
|
||||
dockerfile
|
||||
fish
|
||||
git-rebase
|
||||
gitattributes
|
||||
gitcommit
|
||||
gitignore
|
||||
go
|
||||
haskell
|
||||
hocon
|
||||
html
|
||||
http
|
||||
java
|
||||
javascript
|
||||
json
|
||||
json5
|
||||
jsonc
|
||||
lua
|
||||
make
|
||||
markdown
|
||||
markdown-inline
|
||||
nix
|
||||
proto
|
||||
python
|
||||
rust
|
||||
scala
|
||||
sql
|
||||
swift
|
||||
terraform
|
||||
toml
|
||||
typescript
|
||||
vim
|
||||
xml
|
||||
yaml
|
||||
];
|
||||
|
||||
nixvimInjections = true;
|
||||
|
||||
settings = {
|
||||
highlight.enable = true;
|
||||
indent.enable = true;
|
||||
};
|
||||
folding = false;
|
||||
};
|
||||
|
||||
treesitter-refactor = {
|
||||
enable = true;
|
||||
highlightDefinitions = {
|
||||
enable = true;
|
||||
# Set to false if you have an `updatetime` of ~100.
|
||||
clearOnCursorMove = false;
|
||||
};
|
||||
};
|
||||
|
||||
hmts.enable = true;
|
||||
};
|
||||
}
|
65
programs/nixvim/completion.nix
Normal file
65
programs/nixvim/completion.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.nixvim = {
|
||||
opts.completeopt = [
|
||||
"menu"
|
||||
"menuone"
|
||||
"noselect"
|
||||
];
|
||||
|
||||
plugins = {
|
||||
luasnip.enable = true;
|
||||
|
||||
lspkind = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
cmp = {
|
||||
enable = true;
|
||||
menu = {
|
||||
nvim_lsp = "[LSP]";
|
||||
nvim_lua = "[api]";
|
||||
path = "[path]";
|
||||
luasnip = "[snip]";
|
||||
buffer = "[buffer]";
|
||||
cmp_tabby = "[Tabby]";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
cmp = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
snippet.expand = ''
|
||||
function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end
|
||||
'';
|
||||
|
||||
mapping = {
|
||||
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
|
||||
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
||||
"<C-Space>" = "cmp.mapping.complete()";
|
||||
"<C-e>" = "cmp.mapping.close()";
|
||||
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
|
||||
"<S-Tab>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
|
||||
"<CR>" = "cmp.mapping.confirm({ select = true })";
|
||||
};
|
||||
|
||||
sources = [
|
||||
{ name = "path"; }
|
||||
{ name = "nvim_lsp"; }
|
||||
{ name = "luasnip"; }
|
||||
{
|
||||
name = "buffer";
|
||||
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
21
programs/nixvim/default.nix
Normal file
21
programs/nixvim/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./options.nix
|
||||
./keymappings.nix
|
||||
./completion.nix
|
||||
./_plugins
|
||||
];
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
|
||||
defaultEditor = true;
|
||||
|
||||
nixpkgs.useGlobalPackages = true;
|
||||
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
};
|
||||
}
|
53
programs/nixvim/keymappings.nix
Normal file
53
programs/nixvim/keymappings.nix
Normal file
|
@ -0,0 +1,53 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
programs.nixvim = {
|
||||
keymaps =
|
||||
let
|
||||
normal =
|
||||
lib.mapAttrsToList
|
||||
(
|
||||
key: action: {
|
||||
mode = "n";
|
||||
inherit action key;
|
||||
}
|
||||
)
|
||||
{
|
||||
"<Space>" = "<NOP>";
|
||||
"<esc>" = ":noh<CR>";
|
||||
"Y" = "y$";
|
||||
"<C-c>" = ":b#<CR>";
|
||||
"<C-x>" = ":close<CR>";
|
||||
"<leader>s" = ":w<CR>";
|
||||
"<C-s>" = ":w<CR>";
|
||||
"<leader>h" = "<C-w>h";
|
||||
"<leader>l" = "<C-w>l";
|
||||
"L" = "$";
|
||||
"H" = "^";
|
||||
"<C-Up>" = ":resize -2<CR>";
|
||||
"<C-Down>" = ":resize +2<CR>";
|
||||
"<C-Left>" = ":vertical resize +2<CR>";
|
||||
"<C-Right>" = ":vertical resize -2<CR>";
|
||||
"<M-k>" = ":move-2<CR>";
|
||||
"<M-j>" = ":move+<CR>";
|
||||
};
|
||||
visual =
|
||||
lib.mapAttrsToList
|
||||
(
|
||||
key: action: {
|
||||
mode = "v";
|
||||
inherit action key;
|
||||
}
|
||||
)
|
||||
{
|
||||
">" = ">gv";
|
||||
"<" = "<gv";
|
||||
"<TAB>" = ">gv";
|
||||
"<S-TAB>" = "<gv";
|
||||
"K" = ":m '<-2<CR>gv=gv";
|
||||
"J" = ":m '>+1<CR>gv=gv";
|
||||
};
|
||||
in
|
||||
normal ++ visual;
|
||||
};
|
||||
}
|
36
programs/nixvim/options.nix
Normal file
36
programs/nixvim/options.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.nixvim = {
|
||||
|
||||
clipboard = {
|
||||
register = "unnamedplus";
|
||||
};
|
||||
|
||||
opts = {
|
||||
backup = false;
|
||||
breakindent = true;
|
||||
expandtab = true;
|
||||
hlsearch = true;
|
||||
incsearch = true;
|
||||
mouse = "a";
|
||||
number = true;
|
||||
relativenumber = true;
|
||||
scrolloff = 8;
|
||||
shiftwidth = 2;
|
||||
signcolumn = "yes";
|
||||
smartindent = true;
|
||||
swapfile = false;
|
||||
tabstop = 2;
|
||||
termguicolors = true;
|
||||
undofile = true;
|
||||
updatetime = 250;
|
||||
wrap = false;
|
||||
};
|
||||
|
||||
globals = {
|
||||
mapleader = " ";
|
||||
maplocalleader = " ";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue