editors: enable basic nixvim config

This commit is contained in:
notohh 2024-10-28 19:30:48 -04:00
parent 6a32cb9da2
commit 8c63954273
Signed by: notohh
GPG key ID: BD47506D475EE86D
19 changed files with 277 additions and 0 deletions

View file

@ -0,0 +1,61 @@
{inputs, ...}: {
imports = [
inputs.nixvim.homeManagerModules.nixvim
./plugins
./themes
];
programs.nixvim = {
enable = true;
clipboard.providers.wl-copy.enable = true;
autoGroups = {
vim_enter = {};
};
highlightOverride = {
LspInlayHint.bg = "";
};
autoCmd = [
{
group = "vim_enter";
event = ["VimEnter"];
pattern = "*";
command = "Neotree";
}
];
extraConfigLua = ''
vim.wo.relativenumber = true
'';
extraConfigLuaPre = ''
local slow_format_filetypes = {}
vim.api.nvim_create_user_command("FormatDisable", function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
end, {
desc = "Disable autoformat-on-save",
bang = true,
})
vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = "Re-enable autoformat-on-save",
})
vim.api.nvim_create_user_command("FormatToggle", function(args)
if args.bang then
-- Toggle formatting for current buffer
vim.b.disable_autoformat = not vim.b.disable_autoformat
else
-- Toggle formatting globally
vim.g.disable_autoformat = not vim.g.disable_autoformat
end
end, {
desc = "Toggle autoformat-on-save",
bang = true,
})
'';
};
}

View file

@ -0,0 +1,20 @@
_: {
imports = [
./editor/neotree.nix
./editor/trouble.nix
./editor/autoclose.nix
./editor/bufferline.nix
./editor/autosave.nix
./editor/treesitter.nix
./lsp/lsp.nix
./lsp/conform.nix
./misc/wakatime.nix
./misc/direnv.nix
./misc/presence.nix
./ui/lualine.nix
./ui/mini.nix
./ui/transparent.nix
./ui/telescope.nix
];
programs.nixvim.plugins.web-devicons.enable = true;
}

View file

@ -0,0 +1,5 @@
_: {
programs.nixvim.plugins.autoclose = {
enable = true;
};
}

View file

@ -0,0 +1,3 @@
_: {
programs.nixvim.plugins.auto-save.enable = true;
}

View file

@ -0,0 +1,17 @@
_: {
programs.nixvim.plugins.bufferline = {
enable = true;
settings = {
options = {
offsets = [
{
filetype = "neo-tree";
highlight = "Directory";
text = "File Explorer";
text_align = "center";
}
];
};
};
};
}

View file

@ -0,0 +1,6 @@
_: {
programs.nixvim.plugins.neo-tree = {
enable = true;
enableDiagnostics = true;
};
}

View file

@ -0,0 +1,16 @@
{pkgs, ...}: {
programs.nixvim.plugins.treesitter = {
enable = true;
grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
bash
json
lua
markdown
nix
regex
toml
xml
yaml
];
};
}

View file

@ -0,0 +1,8 @@
_: {
programs.nixvim.plugins.trouble = {
enable = true;
settings = {
auto_refresh = true;
};
};
}

View file

@ -0,0 +1,55 @@
{
pkgs,
lib,
...
}: {
programs.nixvim.plugins.conform-nvim = {
enable = true;
settings = {
formatters_by_ft = {
nix = [
[
"alejandra"
]
];
};
format_on_save = ''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
if slow_format_filetypes[vim.bo[bufnr].filetype] then
return
end
local function on_format(err)
if err and err:match("timeout$") then
slow_format_filetypes[vim.bo[bufnr].filetype] = true
end
end
return { timeout_ms = 200, lsp_fallback = true }, on_format
end
'';
format_after_save = ''
function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
if not slow_format_filetypes[vim.bo[bufnr].filetype] then
return
end
return { lsp_fallback = true }
end
'';
formatters = {
alejandra = {
commmand = "${lib.getExe pkgs.alejandra}";
};
};
};
};
}

View file

@ -0,0 +1,33 @@
_: {
programs.nixvim.plugins = {
lsp-format.enable = true;
lsp-lines.enable = true;
lint = {
lintersByFt = {
nix = [
"statix"
];
};
linters = {
statix = {
cmd = ["statix"];
};
};
};
lsp = {
enable = true;
inlayHints = true;
servers = {
nil_ls = {
enable = true;
};
rust_analyzer = {
enable = true;
autostart = true;
installCargo = true;
installRustc = true;
};
};
};
};
}

View file

@ -0,0 +1,3 @@
_: {
programs.nixvim.plugins.direnv.enable = true;
}

View file

@ -0,0 +1,9 @@
_: {
programs.nixvim.plugins.neocord = {
enable = true;
settings = {
auto_update = true;
enable_line_number = true;
};
};
}

View file

@ -0,0 +1,3 @@
_: {
programs.nixvim.plugins.wakatime.enable = true;
}

View file

@ -0,0 +1,5 @@
_: {
programs.nixvim.plugins.lualine = {
enable = true;
};
}

View file

@ -0,0 +1,5 @@
_: {
programs.nixvim.plugins.mini = {
enable = true;
};
}

View file

@ -0,0 +1,5 @@
_: {
programs.nixvim.plugins.telescope = {
enable = true;
};
}

View file

@ -0,0 +1,12 @@
_: {
programs.nixvim.plugins.transparent = {
enable = true;
settings = {
extra_groups = [
"NeoTreeNormal"
"NeoTreeNormalNC"
"NormalFloat"
];
};
};
}

View file

@ -0,0 +1,3 @@
_: {
imports = [./tokyonight.nix];
}

View file

@ -0,0 +1,8 @@
_: {
programs.nixvim.colorschemes.tokyonight = {
enable = true;
settings = {
transparent = true;
};
};
}