crapload of nvim configuration

This commit is contained in:
cswimr 2025-02-02 18:53:01 -06:00
parent f265752a8a
commit 3a3d4f847b
Signed by: cswimr
GPG key ID: 0EC431A8DA8F8087
17 changed files with 662 additions and 79 deletions

View file

@ -84,7 +84,7 @@
./nixos/gaming.nix
./nixos/gui-pkgs.nix
./nixos/nvidia.nix
./nixos/nvim/nvim.nix
./nixos/nvim
./nixos/ollama.nix
./nixos/pkg.nix
./nixos/shell.nix

18
nixos/nvim/default.nix Normal file
View file

@ -0,0 +1,18 @@
{
imports = [
./keymaps.nix
./settings.nix
./plugins/cmp.nix
./plugins/conform.nix
./plugins/dashboard.nix
./plugins/devcontainer.nix
./plugins/lazygit.nix
./plugins/lsp.nix
./plugins/lualine.nix
./plugins/neo-tree.nix
#./plugins/rooter.nix
./plugins/snacks.nix
./plugins/telescope.nix
];
}

52
nixos/nvim/keymaps.nix Normal file
View file

@ -0,0 +1,52 @@
{
programs.nixvim = {
keymaps = [
{
mode = "n"; # Normal mode
key = "<Space>";
action = "<Nop>";
options.silent = true;
}
{
mode = "n";
key = "<Tab>";
action = ":bnext<CR>";
options = {
desc = "Next Buffer";
silent = true;
};
}
{
mode = "n";
key = "<S-Tab>";
action = ":bprevious<CR>";
options = {
desc = "Previous Buffer";
silent = true;
};
}
{
mode = "n";
key = "<leader>w";
action = ":w<CR>";
options = {
desc = "Save Buffer to File";
silent = true;
};
}
{
mode = "n";
key = "<leader>q";
action = ":qa<CR>";
options = {
desc = "Quit All";
silent = false;
};
}
];
globals = {
mapleader = " ";
maplocalleader = " ";
};
};
}

View file

@ -1,54 +0,0 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [ tmux ];
environment.variables = {
NNN_FIFO = "$XDG_RUNTIME_DIR/nnn.fifo";
NNN_ICONLOOKUP = 1;
};
programs.nixvim = {
extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
# https://github.com/luukvbaal/nnn.nvim
name = "nnn.nvim";
src = pkgs.fetchFromGitHub {
owner = "luukvbaal";
repo = "nnn.nvim";
rev = "662034c73718885ee599ad9fb193ab1ede70fbcb";
sha256 = "sha256-8+ax8n1fA4jgJugvWtRXkad4YM7TmAAsAopzalmGu/4=";
};
})
];
extraConfigLua = ''
local builtin = require("nnn").builtin
require("nnn").setup({
explorer = {
cmd = "nnn -G -Pp",
},
picker = {
cmd = "tmux new-session nnn -G -Pp",
style = { border = "rounded" },
session = "shared",
},
auto_open = {
setup = "explorer",
tabpage = "explorer",
ft_ignore = {
"gitcommit",
},
},
replace_netrw = "picker",
offset = true,
mappings = {
{ "<C-t>", builtin.open_in_tab }, -- open file(s) in tab
{ "<C-s>", builtin.open_in_split }, -- open file(s) in split
{ "<C-v>", builtin.open_in_vsplit }, -- open file(s) in vertical split
{ "<C-p>", builtin.open_in_preview }, -- open file in preview split keeping nnn focused
{ "<C-y>", builtin.copy_to_clipboard }, -- copy file(s) to clipboard
{ "<C-w>", builtin.cd_to_path }, -- cd to file directory
{ "<C-e>", builtin.populate_cmdline }, -- populate cmdline (:) with file(s)
},
})
'';
};
}

View file

@ -1,24 +0,0 @@
{ pkgs, ... }:
{
imports = [
./nnn.nix
];
programs.nixvim = {
extraPackages = with pkgs; [ fd ];
enable = true;
viAlias = true;
vimAlias = true;
colorschemes.catppuccin.enable = true;
plugins = {
conform-nvim = {
enable = true;
};
treesitter.enable = true;
cmp.enable = true;
cmp-nvim-lsp.enable = true;
lsp.enable = true;
bufferline.enable = true;
};
};
}

View file

@ -0,0 +1,16 @@
{
programs.nixvim = {
plugins = {
cmp = {
enable = true;
settings.sources = [
{ name = "nvim_lsp"; }
{ name = "buffer"; }
{ name = "path"; }
];
};
copilot-lua.enable = true;
copilot-cmp.enable = true;
};
};
}

View file

@ -0,0 +1,152 @@
{ pkgs, lib, ... }:
{
programs.nixvim = {
extraPackages = with pkgs; [
shellcheck
shellharden
shfmt
ruff
stylua
nixfmt-rfc-style
clang-tools
csharpier
];
plugins = {
conform-nvim = {
enable = true;
settings = {
formatters_by_ft = {
bash = [
"shellcheck"
"shellharden"
"shfmt"
];
python = [
"ruff_fix"
"ruff_format"
"ruff_organize_imports"
];
c = [ "clang-format" ];
cpp = [ "clang-format" ];
cs = [ "csharpier" ];
csharp = [ "csharpier" ];
lua = [ "stylua" ];
nix = [ "nixfmt" ];
javascript = [ "prettier" ];
javascriptreact = [ "prettier" ];
typescript = [ "prettier" ];
typescriptreact = [ "prettier" ];
markdown = [ "prettier" ];
yaml = [ "prettier" ];
json = [ "prettier" ];
svelte = [ "prettier" ];
html = [ "prettier" ];
css = [ "prettier" ];
graphql = [ "prettier" ];
"_" = [
"trim_whitespace"
"trim_newlines"
];
format_on_save = # Lua
''
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 = # Lua
''
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
'';
log_level = "warn";
notify_on_error = true;
notify_no_formatters = true;
default_format_opts = {
lsp_format = "fallback";
timeout_ms = 300;
};
formatters = {
shellcheck = {
command = lib.getExe pkgs.shellcheck;
};
shfmt = {
command = lib.getExe pkgs.shfmt;
};
shellharden = {
command = lib.getExe pkgs.shellharden;
};
nixfmt = {
command = lib.getExe pkgs.nixfmt-rfc-style;
};
stylua = {
command = lib.getExe pkgs.stylua;
};
clang-format = {
command = "${pkgs.clang-tools}/bin/clang-format";
};
csharpier = {
command = lib.getExe pkgs.csharpier;
};
ruff_fix = {
command = lib.getExe pkgs.ruff;
};
ruff_format = {
command = lib.getExe pkgs.ruff;
};
ruff_organize_imports = {
command = lib.getExe pkgs.ruff;
};
};
};
};
luaConfig.post = ''
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 })
'';
};
};
keymaps = [
{
mode = "n";
key = "<leader>f";
action = ":Format<cr>";
options = {
desc = "Format";
silent = true;
};
}
];
};
}

View file

@ -0,0 +1,48 @@
{
programs.nixvim.plugins = {
dashboard = {
enable = true;
settings = {
change_to_vcs_root = true;
config = {
footer = [
"Made with "
];
header = [
" "
" "
" "
" "
" "
" "
];
mru = {
limit = 20;
};
project = {
enable = true;
};
shortcut = [
{
action = {
__raw = "function(path) vim.cmd('Telescope find_files') end";
};
desc = "Files";
group = "Label";
icon = " ";
icon_hl = "@variable";
key = "f";
}
{
action = "Telescope repo list";
desc = " Projects";
group = "DiagnosticHint";
key = "p";
}
];
};
theme = "hyper";
};
};
};
}

View file

@ -0,0 +1,20 @@
{ pkgs, ... }:
{
programs.nixvim = {
extraPackages = with pkgs; [ devcontainer ];
extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
# https://codeberg.org/esensar/nvim-dev-container
name = "nvim-dev-container";
src = pkgs.fetchgit {
url = "https://codeberg.org/esensar/nvim-dev-container";
rev = "ba9666bdaec23cfe8087c0b6bb0a15c93ec8ba87";
sha256 = "sha256-x1+HxC/wDsR1MukXzteIcoOeUJ8XxXvbujL5/XPvf6Q=";
};
})
];
extraConfigLua = ''
require("devcontainer").setup({})
'';
};
}

View file

@ -0,0 +1,19 @@
{
programs.nixvim = {
plugins.lazygit = {
enable = true;
};
extraConfigLua = ''require("telescope").load_extension("lazygit")'';
keymaps = [
{
mode = "n";
key = "<leader>g";
action = "<cmd>LazyGit<cr>";
options = {
desc = "LazyGit";
silent = true;
};
}
];
};
}

129
nixos/nvim/plugins/lsp.nix Normal file
View file

@ -0,0 +1,129 @@
{ pkgs, ... }:
{
programs.nixvim = {
extraPackages = with pkgs; [
basedpyright
ruff
nil
nixfmt-rfc-style
(callPackage ../../../packages/luau-lsp.nix { inherit pkgs; })
];
plugins = {
lsp = {
enable = true;
postConfig = ''
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup('lsp_attach_disable_ruff_hover', { clear = true }),
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client == nil then
return
end
if client.name == 'ruff' then
-- Disable hover in favor of Pyright
client.server_capabilities.hoverProvider = false
end
end,
desc = 'LSP: Disable hover capability from Ruff',
})
require('lspconfig').basedpyright.setup { settings = { pyright = { disableOrganizeImports = true } } }
require('lspconfig').ruff.setup { }
require('lspconfig').nil_ls.setup {
cmd = { "${pkgs.nil}/bin/nil" },
settings = {
['nil'] = {
formatting = {
command = { "${pkgs.nixfmt-rfc-style}/bin/nixfmt" },
},
},
},
}
--require('luau-lsp').setup { }
'';
};
trouble = {
enable = true;
settings = {
auto_refresh = true;
};
};
};
extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
# https://github.com/lopi-py/luau-lsp.nvim
name = "luau-lsp.nvim";
src = pkgs.fetchFromGitHub {
owner = "lopi-py";
repo = "luau-lsp.nvim";
rev = "v1.6.0";
sha256 = "sha256-8+ax8n1fA4jgJugvWtRXkad4YM7TmAAsAopzalmGu/4=";
};
})
];
keymaps = [
{
mode = "n";
key = "<leader>x";
action = ":Trouble<CR>";
options = {
desc = "Trouble";
silent = true;
};
}
{
mode = "n";
key = "<leader>xx";
action = ":Trouble diagnostics toggle<CR>";
options = {
desc = "Diagnostics (Trouble)";
silent = true;
};
}
{
mode = "n";
key = "<leader>xX";
action = ":Trouble diagnostics toggle filter.buf=0<CR>";
options = {
desc = "Buffer Diagnostics (Trouble)";
silent = true;
};
}
{
mode = "n";
key = "<leader>xs";
action = ":Trouble symbols toggle focus=false<CR>";
options = {
desc = "Symbols (Trouble)";
silent = true;
};
}
{
mode = "n";
key = "<leader>xd";
action = ":Trouble lsp_definitions toggle<CR>";
options = {
desc = "LSP Definitions / references / ... (Trouble)";
silent = true;
};
}
{
mode = "n";
key = "<leader>xl";
action = ":Trouble loclist toggle<CR>";
options = {
desc = "Location List (Trouble)";
silent = true;
};
}
{
mode = "n";
key = "<leader>xq";
action = ":Trouble qflist toggle<CR>";
options = {
desc = "Quickfix (Trouble)";
silent = true;
};
}
];
};
}

View file

@ -0,0 +1,8 @@
{
programs.nixvim = {
plugins.lualine = {
enable = true;
settings = { };
};
};
}

View file

@ -0,0 +1,19 @@
{
programs.nixvim = {
plugins.neo-tree = {
enable = true;
enableGitStatus = true;
};
keymaps = [
{
mode = "n";
key = "<leader>e";
action = ":Neotree toggle<CR>";
options = {
desc = "Toggle Neotree";
silent = true;
};
}
];
};
}

View file

@ -0,0 +1,20 @@
{ pkgs, ... }:
{
programs.nixvim = {
extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
# https://codeberg.org/esensar/nvim-dev-container
name = "vim-rooter";
src = pkgs.fetchFromGitHub {
owner = "airblade";
repo = "vim-rooter";
rev = "51402fb77c4d6ae94994e37dc7ca13bec8f4afcc";
sha256 = "sha256-JrpYcQ/mJQQUvDdsYlaaep6J6/irDIrCAb8W49JHqzk=";
};
})
];
extraConfigLua = ''
require("vim-rooter").setup({})
'';
};
}

View file

@ -0,0 +1,14 @@
{
programs.nixvim = {
plugins.snacks = {
enable = true;
settings = {
bigfile.enabled = true;
notifier = {
enable = true;
timeout = 3000;
};
};
};
};
}

View file

@ -0,0 +1,114 @@
{ pkgs, ... }:
{
programs.nixvim = {
extraPackages = with pkgs; [
fd
plocate
glow
];
plugins = {
telescope = {
enable = true;
extensions = {
fzf-native.enable = true;
};
enabledExtensions = [
"repo"
];
settings = {
defaults = {
layout_config = {
prompt_position = "bottom";
};
};
};
};
};
extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
# https://codeberg.org/esensar/nvim-dev-container
name = "telescope-repo.nvim";
src = pkgs.fetchFromGitHub {
owner = "cljoly";
repo = "telescope-repo.nvim";
rev = "a5395a4bf0fd742cc46b4e8c50e657062f548ba9";
sha256 = "sha256-cIovB45hfG4lDK0VBIgK94dk2EvGXZtfAJETkQ+lrcw=";
};
})
];
keymaps = [
{
mode = "n";
key = "<leader>t";
action = ":Telescope<CR>";
options = {
desc = "Telescope";
silent = true;
};
}
{
mode = "n";
key = "<leader>tf";
action = ":Telescope find_files<CR>";
options = {
desc = "Find Files";
silent = true;
};
}
{
mode = "n";
key = "<leader>tg";
action = ":Telescope live_grep<CR>";
options = {
desc = "Live Grep";
silent = true;
};
}
{
mode = "n";
key = "<leader>tb";
action = ":Telescope buffers<CR>";
options = {
desc = "Buffers";
silent = true;
};
}
{
mode = "n";
key = "<leader>fc";
action = ":Telescope colorscheme<CR>";
options = {
desc = "Color Schemes";
silent = true;
};
}
{
mode = "n";
key = "<leader>tk";
action = ":Telescope keymaps<CR>";
options = {
desc = "Keymaps";
silent = true;
};
}
{
mode = "n";
key = "<leader>tp";
action = ":Telescope repo list<CR>";
options = {
desc = "Projects";
silent = true;
};
}
{
mode = "n";
key = "<leader>tc";
action = ":Telescope commands<CR>";
options = {
desc = "Commands";
silent = true;
};
}
];
};
}

32
nixos/nvim/settings.nix Executable file
View file

@ -0,0 +1,32 @@
{ pkgs, ... }:
{
programs.nixvim = {
extraPackages = with pkgs; [ fd ];
enable = true;
viAlias = true;
vimAlias = true;
colorschemes.catppuccin.enable = true;
plugins = {
# lz-n = {
# enable = true;
# lazyLoad = {
# enable = true;
# };
# };
treesitter.enable = true;
direnv.enable = true;
web-devicons.enable = true;
bufferline.enable = true;
glow.enable = true;
gitblame.enable = true;
git-conflict.enable = true;
nix.enable = true;
nix-develop.enable = true;
image.enable = true;
which-key.enable = true;
neocord.enable = true;
rainbow-delimiters.enable = true;
neoconf.enable = true;
};
};
}