nvim: move to services we do not specify a pkgset

This commit is contained in:
Kevin Baensch 2025-07-05 20:08:20 +02:00
parent 465a6b19d1
commit 11b98d8146
Signed by: derped
GPG key ID: C0F1D326C7626543
45 changed files with 38 additions and 37 deletions

42
services/nvim.nix Normal file
View file

@ -0,0 +1,42 @@
{
lib,
config,
fn,
nvim-lazy,
...
}:
with lib;
{
imports =
[
nvim-lazy.nixosModules.nvim-lazy
]
++ (fn.lst {
path = (toString ./nvim);
fullPath = true;
});
programs.nvim-lazy = mkIf (elem "nvim" config.machine.pkgs) {
enable = true;
luaRcContent = # lua
''
vim.g.mapleader = " "
vim.o.tabstop = 2
vim.o.shiftwidth = 2
vim.o.expandtab = true
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.nrformats = alpha
vim.bo.softtabstop = 2
vim.wo.foldmethod = 'expr'
vim.wo.foldexpr = 'nvim_treesitter#foldexpr()'
vim.o.foldlevelstart = 99
vim.wo.number = true
vim.wo.relativenumber = true
vim.o.scrolloff = 20
'';
};
}

49
services/nvim/blink.nix Normal file
View file

@ -0,0 +1,49 @@
{ config, lib, ... }:
lib.mkIf (lib.elem "nvim::blink" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
dir = vPlug: vPlug.friendly-snippets;
}
{
dir = vPlug: vPlug.blink-cmp;
dependencies = vPlug: with vPlug; [ friendly-snippets ];
opts = {
# 'default' for mappings similar to built-in completion
# 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate)
# 'enter' for mappings similar to 'super-tab' but with 'enter' to accept
# See the full "keymap" documentation for information on defining your own keymap.
keymap = {
preset = "default";
# "[\"<S-Tab>\"]" = [ "select_prev" "fallback" ];
# "[\"<Tab>\"]" = [ "select_next" "fallback" ];
};
appearance = {
# Sets the fallback highlight groups to nvim-cmp's highlight groups
# Useful for when your theme doesn't support blink.cmp
# Will be removed in a future release
use_nvim_cmp_as_default = true;
# Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
# Adjusts spacing to ensure icons are aligned
nerd_font_variant = "mono";
};
fuzzy = {
implementation = "rust";
};
# Default list of enabled providers defined so that you can extend it
# elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = [
"lsp"
"path"
"snippets"
"buffer"
];
};
};
# opts_extend = [ "sources.default" ];
}
];
}

43
services/nvim/cmp.nix Normal file
View file

@ -0,0 +1,43 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::cmp" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
# Autocompletion
{
dir = vPlug: vPlug.nvim-cmp;
event = [ "InsertEnter" ];
dependencies = (
vPlug: with vPlug; [
luasnip
]
);
config = # lua
''
function()
local cmp = require('cmp')
cmp.setup({
${lib.optionalString (lib.elem "nvim::lsp" config.machine.pkgs) # lua
''sources = { { name = 'nvim_lsp' }, },''
}
mapping = cmp.mapping.preset.insert({
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
})
})
end
'';
}
{
dir = vPlug: vPlug.luasnip;
lazy = true;
}
];
}

View file

@ -0,0 +1,52 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::fugitive" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
dir = vPlug: vPlug.neogit;
dependencies = (
vPlug: with vPlug; [
plenary-nvim
diffview-nvim
telescope-nvim
]
);
cmd = [ "Neogit" ];
keys = [
{
bind = "<leader>gm";
cmd = "<Cmd>Neogit<CR>";
opts = {
desc = "Open Neogit.";
};
}
];
config = true;
}
{
lazy = true;
dir = vPlug: vPlug.diffview-nvim;
}
{
enabled = true;
lazy = true;
dir = vPlug: vPlug.fugitive;
cmd = [ "Git" ];
keys = [
{
bind = "<leader>gs";
cmd = "<Cmd>Git<CR>";
opts = {
desc = "Open fugitive (git status)";
};
}
# { bind = "<leader>ga"; cmd = "<Cmd>Git<CR>"; opts = { desc = "Open fugitive (git status)"; }; }
];
}
];
}

18
services/nvim/gen.nix Normal file
View file

@ -0,0 +1,18 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::gen" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
short = "David-Kunz/gen.nvim";
cmd = [ "Gen" ];
opts = {
model = "deepseek-coder:1.3b-base-q4_0";
};
}
];
}

147
services/nvim/go.nix Normal file
View file

@ -0,0 +1,147 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::go" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
dir = (vPlug: vPlug.go-nvim);
dependencies = (
vPlug: with vPlug; [
"nvim-treesitter"
nvim-lspconfig
]
);
ft = [
"go"
"gomod"
"ray-x/guihua.lua"
];
config = # lua
''
function()
require('go').setup({
disable_defaults = false, -- true|false when true set false to all boolean settings and replace all table
-- settings with {}
go='go', -- go command, can be go[default] or go1.18beta1
goimports ='gopls', -- goimports command, can be gopls[default] or either goimports or golines if need to split long lines
gofmt = 'gopls', -- gofmt through gopls: alternative is gofumpt, goimports, golines, gofmt, etc
fillstruct = 'gopls', -- set to fillstruct if gopls fails to fill struct
max_line_len = 0, -- max line length in golines format, Target maximum line length for golines
tag_transform = false, -- can be transform option("snakecase", "camelcase", etc) check gomodifytags for details and more options
tag_options = 'json=omitempty', -- sets options sent to gomodifytags, i.e., json=omitempty
gotests_template = "", -- sets gotests -template parameter (check gotests for details)
gotests_template_dir = "", -- sets gotests -template_dir parameter (check gotests for details)
comment_placeholder = "" , -- comment_placeholder your cool placeholder e.g. 󰟓
icons = {breakpoint = '🧘', currentpos = '🏃'}, -- setup to `false` to disable icons setup
verbose = false, -- output loginf in messages
lsp_cfg = true, -- true: use non-default gopls setup specified in go/lsp.lua
-- false: do nothing
-- if lsp_cfg is a table, merge table with with non-default gopls setup in go/lsp.lua, e.g.
-- lsp_cfg = {settings={gopls={matcher='CaseInsensitive', ['local'] = 'your_local_module_path', gofumpt = true }}}
lsp_gofumpt = true, -- true: set default gofmt in gopls format to gofumpt
-- false: do not set default gofmt in gopls format to gofumpt
lsp_on_attach = nil, -- nil: use on_attach function defined in go/lsp.lua,
-- when lsp_cfg is true
-- if lsp_on_attach is a function: use this function as on_attach function for gopls
lsp_keymaps = false, -- set to false to disable gopls/lsp keymap
lsp_codelens = true, -- set to false to disable codelens, true by default, you can use a function
-- function(bufnr)
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>F", "<cmd>lua vim.lsp.buf.formatting()<CR>", {noremap=true, silent=true})
-- end
-- to setup a table of codelens
diagnostic = { -- set diagnostic to false to disable vim.diagnostic setup
hdlr = false, -- hook lsp diag handler and send diag to quickfix
underline = true,
-- virtual text setup
virtual_text = { spacing = 0, prefix = '' },
signs = true,
update_in_insert = false,
},
-- if you need to setup your ui for input and select, you can do it here
-- go_input = require('guihua.input').input -- set to vim.ui.input to disable guihua input
-- go_select = require('guihua.select').select -- vim.ui.select to disable guihua select
lsp_document_formatting = true,
-- set to true: use gopls to format
-- false if you want to use other formatter tool(e.g. efm, nulls)
lsp_inlay_hints = {
enable = true,
-- hint style, set to 'eol' for end-of-line hints, 'inlay' for inline hints
-- inlay only avalible for 0.10.x
style = 'inlay',
-- Note: following setup only works for style = 'eol', you do not need to set it for 'inlay'
-- Only show inlay hints for the current line
only_current_line = false,
-- Event which triggers a refersh of the inlay hints.
-- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but
-- not that this may cause higher CPU usage.
-- This option is only respected when only_current_line and
-- autoSetHints both are true.
only_current_line_autocmd = "CursorHold",
-- whether to show variable name before type hints with the inlay hints or not
-- default: false
show_variable_name = true,
-- prefix for parameter hints
parameter_hints_prefix = "󰊕 ",
show_parameter_hints = true,
-- prefix for all the other hints (type, chaining)
other_hints_prefix = "=> ",
-- whether to align to the lenght of the longest line in the file
max_len_align = false,
-- padding from the left if max_len_align is true
max_len_align_padding = 1,
-- whether to align to the extreme right or not
right_align = false,
-- padding from the right if right_align is true
right_align_padding = 6,
-- The color of the hints
highlight = "Comment",
},
gopls_cmd = nil, -- if you need to specify gopls path and cmd, e.g {"/home/user/lsp/gopls", "-logfile","/var/log/gopls.log" }
gopls_remote_auto = true, -- add -remote=auto to gopls
gocoverage_sign = "",
sign_priority = 5, -- change to a higher number to override other signs
dap_debug = true, -- set to false to disable dap
dap_debug_keymap = true, -- true: use keymap for debugger defined in go/dap.lua
-- false: do not use keymap in go/dap.lua. you must define your own.
-- Windows: Use Visual Studio keymap
dap_debug_gui = {}, -- bool|table put your dap-ui setup here set to false to disable
dap_debug_vt = { enabled_commands = true, all_frames = true }, -- bool|table put your dap-virtual-text setup here set to false to disable
dap_port = 38697, -- can be set to a number, if set to -1 go.nvim will pick up a random port
dap_timeout = 15, -- see dap option initialize_timeout_sec = 15,
dap_retries = 20, -- see dap option max_retries
build_tags = "tag1,tag2", -- set default build tags
textobjects = true, -- enable default text objects through treesittter-text-objects
test_runner = 'go', -- one of {`go`, `dlv`, `ginkgo`, `gotestsum`}
verbose_tests = true, -- set to add verbose flag to tests deprecated, see '-v' option
run_in_floaterm = false, -- set to true to run in a float window. :GoTermClose closes the floatterm
-- float term recommend if you use gotestsum ginkgo with terminal color
floaterm = { -- position
posititon = 'auto', -- one of {`top`, `bottom`, `left`, `right`, `center`, `auto`}
width = 0.45, -- width of float window if not auto
height = 0.98, -- height of float window if not auto
title_colors = 'nord', -- default to nord, one of {'nord', 'tokyo', 'dracula', 'rainbow', 'solarized ', 'monokai'}
-- can also set to a list of colors to define colors to choose from
-- e.g {'#D8DEE9', '#5E81AC', '#88C0D0', '#EBCB8B', '#A3BE8C', '#B48EAD'}
},
trouble = false, -- true: use trouble to open quickfix
test_efm = false, -- errorfomat for quickfix, default mix mode, set to true will be efm only
luasnip = false, -- enable included luasnip snippets. you can also disable while add lua/snips folder to luasnip load
-- Do not enable this if you already added the path, that will duplicate the entries
on_jobstart = function(cmd) _=cmd end, -- callback for stdout
on_stdout = function(err, data) _, _ = err, data end, -- callback when job started
on_stderr = function(err, data) _, _ = err, data end, -- callback for stderr
on_exit = function(code, signal, output) _, _, _ = code, signal, output end, -- callback for jobexit, output : string
iferr_vertical_shift = 4 -- defines where the cursor will end up vertically from the begining of if err statement
})
end
'';
}
"ray-x/guihua.lua"
];
}

88
services/nvim/harpoon.nix Normal file
View file

@ -0,0 +1,88 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::harpoon" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
dir = vPlug: vPlug.harpoon2;
lazy = true;
keys =
[
{
bind = "<leader>ha";
cmdIsFunction = true;
cmd = # lua
''
function()
require("harpoon"):list():add()
end
'';
}
{
bind = "<leader>he";
cmdIsFunction = true;
cmd = # lua
''
function()
local harpoon = require("harpoon")
harpoon.ui:toggle_quick_menu(harpoon:list())
end
'';
}
{
bind = "<C-h>";
cmdIsFunction = true;
cmd = # lua
''
function()
require("harpoon"):list():select(1)
end
'';
}
{
bind = "<C-j>";
cmdIsFunction = true;
cmd = # lua
''
function()
require("harpoon"):list():select(2)
end
'';
}
{
bind = "<C-k>";
cmdIsFunction = true;
cmd = # lua
''
function()
require("harpoon"):list():select(3)
end
'';
}
{
bind = "<C-l>";
cmdIsFunction = true;
cmd = # lua
''
function()
require("harpoon"):list():select(4)
end
'';
}
]
++ (map (num: {
bind = "<leader>h${toString (lib.mod num 10)}";
cmdIsFunction = true;
cmd = # lua
''
function()
require("harpoon"):list():select(${toString num})
end
'';
}) (lib.range 1 10));
}
];
}

91
services/nvim/hurl.nix Normal file
View file

@ -0,0 +1,91 @@
{
lib,
config,
pkgs,
...
}:
lib.mkIf (lib.elem "nvim::hurl" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
dir = vPlug: vPlug.nui-nvim;
}
{
lazy = true;
ft = [ "hurl" ];
short = "jellydn/hurl.nvim";
dependencies = (vPlug: with vPlug; [ nui-nvim ]);
opts = {
debug = false;
show_notification = false;
# Show response in popup or split
mode = "popup";
formatters = {
json = [ "${pkgs.jq}/bin/jq" ];
html = [
"${pkgs.nodePackages.prettier}/bin/prettier"
"--parser"
"html"
];
};
};
keys = [
{
bind = "<leader>A";
cmd = "<cmd>HurlRunner<CR>";
opts = {
ft = "hurl";
desc = "Run All requests";
};
}
{
bind = "<leader>a";
cmd = "<cmd>HurlRunnerAt<CR>";
opts = {
ft = "hurl";
desc = "Run Api request";
};
}
{
bind = "<leader>te";
cmd = "<cmd>HurlRunnerToEntry<CR>";
opts = {
ft = "hurl";
desc = "Run Api request to entry";
};
}
{
bind = "<leader>tm";
cmd = "<cmd>HurlToggleMode<CR>";
opts = {
ft = "hurl";
desc = "Hurl Toggle Mode";
};
}
{
bind = "<leader>tv";
cmd = "<cmd>HurlVerbose<CR>";
opts = {
ft = "hurl";
desc = "Run Api in verbose mode";
};
}
{
bind = "<leader>h";
cmd = ":HurlRunner<CR>";
opts = {
ft = "hurl";
desc = "Hurl Runner";
mode = "v";
};
}
];
}
{
lazy = true;
ft = [ "hurl" ];
dir = vPlug: vPlug.hurl;
}
];
}

23
services/nvim/image.nix Normal file
View file

@ -0,0 +1,23 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::image" config.machine.pkgs) {
programs.nvim-lazy = {
lazyPlugins = [
{
lazy = false;
dir = vPlug: vPlug.image-nvim;
opts = {
processor = "magick_cli";
integrations.markdown = {
only_render_image_at_cursor = true;
};
};
}
];
extraLuaPackages = p: [ p.magick ];
};
}

View file

@ -0,0 +1,23 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::kanagawa-nvim" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
dir = vPlug: vPlug.kanagawa-nvim;
priority = 1000;
config = # lua
''
function()
require('kanagawa').setup({
transparent = true,
})
vim.cmd([[colorscheme kanagawa-wave]])
end
'';
}
];
}

136
services/nvim/lsp.nix Normal file
View file

@ -0,0 +1,136 @@
{
lib,
config,
pkgs,
fn,
...
}@inputs:
lib.mkIf (lib.elem "nvim::lsp" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
# Yaml schema store for yamlls
{
lazy = true;
dir = vPlug: vPlug.SchemaStore-nvim;
}
# {
# dir = vPlug: vPlug.cmp-nvim-lsp;
# lazy = true;
# }
{
dir = vPlug: vPlug.nvim-lspconfig;
cmd = [ "LspInfo" ];
event = [
"BufReadPre"
"BufNewFile"
];
dependencies = (
vPlug: with vPlug; [
# cmp-nvim-lsp
blink-cmp
SchemaStore-nvim
# coq_nvim
]
);
init = # lua
''
function()
-- Reserve a space in the gutter
-- This will avoid an annoying layout shift in the screen
vim.opt.signcolumn = 'yes'
vim.diagnostic.config({
virtual_text = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = '',
[vim.diagnostic.severity.WARN] = '',
[vim.diagnostic.severity.HINT] = '',
[vim.diagnostic.severity.INFO] = '»',
},
},
})
---Force a specific language for ltex-ls
---@param lang string
function SetLtexLang(lang)
local clients = vim.lsp.get_clients({ buffer = 0 })
for _, client in ipairs(clients) do
if client.name == "ltex" then
vim.api.nvim_notify("Set ltex-ls lang to " .. lang, vim.log.levels.INFO, { title = "LTex Language", timeout = 2000, })
client.config.settings.ltex.language = lang
vim.lsp.buf_notify(0, "workspace/didChangeConfiguration", { settings = client.config.settings })
return
end
end
end
end
'';
opts = {
inlay_hints = {
enabled = true;
};
servers = lib.foldl (l: r: l // r) { } (
lib.map (path: import "${path}" (inputs // { inherit pkgs; })) (
fn.lst {
path = ((toString ./.) + "/lsp");
fullPath = true;
}
)
);
};
config = # lua
''
function(_, opts)
local lsp_defaults = require('lspconfig').util.default_config
-- Add cmp_nvim_lsp capabilities settings to lspconfig
-- This should be executed before you configure any language server
-- lsp_defaults.capabilities = vim.tbl_deep_extend(
-- 'force',
-- lsp_defaults.capabilities
-- require('cmp_nvim_lsp').default_capabilities()
-- )
-- LspAttach is where you enable features that only work
-- if there is a language server active in the file
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions',
callback = function(event)
local opts = {buffer = event.buf}
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
end,
})
local lspconfig = require('lspconfig')
for server, config in pairs(opts.servers) do
${lib.optionalString (lib.elem "nvim::blink" config.machine.pkgs) # lua
''
-- passing config.capabilities to blink.cmp merges with the capabilities in your
-- `opts[server].capabilities, if you've defined it
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
''
}
vim.lsp.enable(server)
vim.lsp.config(server, config)
end
end
'';
}
];
}

View file

@ -0,0 +1,15 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::bash" config.machine.pkgs) {
bashls = {
cmd = [
"${pkgs.nodePackages.bash-language-server}/bin/bash-language-server"
"start"
];
};
}

21
services/nvim/lsp/c.nix Normal file
View file

@ -0,0 +1,21 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::c" config.machine.pkgs) {
ccls = {
cmd = [ "${pkgs.ccls}/bin/ccls" ];
init_options = {
# compilationDatabaseDirectory = "build";
index = {
threads = 0;
};
clang = {
excludeArgs = [ "-frounding-math" ];
};
};
};
}

View file

@ -0,0 +1,15 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::emmet" config.machine.pkgs) {
emmet_language_server = {
cmd = [
"${pkgs.emmet-language-server}/bin/emmet-language-server"
"--stdio"
];
};
}

12
services/nvim/lsp/go.nix Normal file
View file

@ -0,0 +1,12 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::go" config.machine.pkgs) {
gopls = {
cmd = [ "${pkgs.gopls}/bin/gopls" ];
};
}

View file

@ -0,0 +1,15 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::harper" config.machine.pkgs) {
harper_ls = {
cmd = [
"${pkgs.harper}/bin/harper-ls"
"--stdio"
];
};
}

View file

@ -0,0 +1,15 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::html" config.machine.pkgs) {
# local html_capabilities = vim.lsp.protocol.make_client_capabilities()
# html_capabilities.textDocument.completion.completionItem.snippetSupport = true
html = {
capabilities = _: "vim.lsp.protocol.make_client_capabilities()";
cmd = [ "${pkgs.vscode-langservers-extracted}/bin/vscode-html-language-server" ];
};
}

View file

@ -0,0 +1,27 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::ltex" config.machine.pkgs) {
ltex = {
cmd = [ "${pkgs.ltex-ls}/bin/ltex-ls" ];
settings = {
ltex = {
language = "de-DE";
};
};
on_attach =
_: # lua
''
function(client, bufnr)
vim.api.nvim_create_user_command(
"LtexLang",
"lua SetLtexLang(<q-args>)",
{ nargs = 1, desc = "Set ltex-ls language" }
)
end'';
};
}

25
services/nvim/lsp/lua.nix Normal file
View file

@ -0,0 +1,25 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::lua" config.machine.pkgs) {
lua_ls = {
cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ];
settings = {
Lua = {
runtime = {
version = "LuaJIT";
};
workspace = {
checkThirdParty = false;
library = [
(_: "vim.env.VIMRUNTIME")
];
};
};
};
};
}

View file

@ -0,0 +1,15 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::markdown" config.machine.pkgs) {
marksman = {
cmd = [
"${pkgs.marksman}/bin/marksman"
"server"
];
};
}

View file

@ -0,0 +1,25 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::nix-nil" config.machine.pkgs) {
nil_ls = {
cmd = [ "${pkgs.nil}/bin/nil" ];
settings = {
"['nil']" = {
formatting = {
command = [ "${pkgs.nixfmt-rfc-style}/bin/nixfmt" ];
};
maxMemoryMB = 4069;
# nix = {
# flake = {
# autoEvalInputs = true;
# };
# };
};
};
};
}

View file

@ -0,0 +1,46 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::nix-nixd" config.machine.pkgs) {
nixd = {
cmd = [ "${pkgs.nixd}/bin/nixd" ];
settings = {
nixd = {
on_init =
_: # lua
''
function(client)
local path = client.workspace_folders[1].name
if path == '/path/to/project1' then
client.config.settings["rust-analyzer"].checkOnSave.overrideCommand = { "cargo", "check" }
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end
return true
end
'';
nixpkgs = {
expr = ''import (builtins.getFlake ("git+file:///etc/nixos")).inputs.nixpkgs {}'';
};
formatting = {
command = [ "${pkgs.nixfmt-rfc-style}/bin/nixfmt" ];
};
options = {
nixos = {
expr = ''(builtins.getFlake ("git+file:///etc/nixos")).outputs.nixosConfigurations.Lilim.options'';
};
# TODO: Find a good general expression for this.
# home_manager = {
# expr =
# "'(builtins.getFlake (\"git+file://\" + toString ./.)).homeConfigurations.\"ruixi@k-on\".options'";
# };
};
};
};
};
}

21
services/nvim/lsp/php.nix Normal file
View file

@ -0,0 +1,21 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::php" config.machine.pkgs) {
phpactor = {
cmd = [
"${pkgs.phpactor}/bin/phpactor"
"language-server"
];
init_options = {
"[\"symfony.enabled\"]" = true;
"[\"language_server_phpstan.enabled\"]" = true;
"[\"language_server_phpstan.bin\"]" = "${pkgs.phpPackages.phpstan}/bin/phpstan";
"[\"language_server_phpstan.level\"]" = 5;
};
};
}

View file

@ -0,0 +1,54 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::python" config.machine.pkgs) {
pyright = {
cmd = [
"${pkgs.pyright}/bin/pyright-langserver"
"--stdio"
];
settings = {
pyright = {
disableOrganizeImports = true;
};
python = {
# analysis = {
# ignore = { '*' },
# },
};
};
};
ruff = {
cmd = [
"${pkgs.ruff}/bin/ruff"
"server"
"--preview"
];
init_options = {
settings = {
# Modification to any of these settings has no effect.
enable = true;
ignoreStandardLibrary = true;
organizeImports = true;
fixAll = true;
lineLength = 120;
lint = {
enable = true;
run = "onType";
};
};
};
on_attach =
_: # lua
''
function(client, bufnr)
if client.name == 'ruff' then
client.server_capabilities.hoverProvider = false;
end
end'';
};
}

View file

@ -0,0 +1,17 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::rust" config.machine.pkgs) {
rust_analyzer = {
cmd = [
"${pkgs.rustup}/bin/rustup"
"run"
"nightly"
"rust-analyzer"
];
};
}

View file

@ -0,0 +1,15 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::typescript" config.machine.pkgs) {
ts_ls = {
cmd = [
"${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server"
"--stdio"
];
};
}

View file

@ -0,0 +1,26 @@
{
lib,
config,
pkgs,
...
}:
lib.optionalAttrs (lib.elem "nvim::lsp::yaml" config.machine.pkgs) {
yamlls = {
cmd = [
"${pkgs.yaml-language-server}/bin/yaml-language-server"
"--stdio"
];
settings = {
yaml = {
schemaStore = {
# Disable to use Store from SchemaStore-nvim plugin
enable = false;
# Avoid TypeError: Cannot read properties of undefined (reading 'length')
url = "";
};
schemas = _: "require('schemastore').yaml.schemas()";
};
};
};
}

72
services/nvim/lualine.nix Normal file
View file

@ -0,0 +1,72 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::lualine" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
dir = vPlug: vPlug.lualine-nvim;
dependencies = (vPlug: with vPlug; [ nvim-web-devicons ]);
opts = {
options = {
icons_enabled = true;
theme = "auto";
component_separators = {
left = "";
right = "";
};
section_separators = {
left = "";
right = "";
};
disabled_filetypes = {
statusline = { };
winbar = { };
};
ignore_focus = { };
always_divide_middle = true;
globalstatus = false;
refresh = {
statusline = 1000;
tabline = 1000;
winbar = 1000;
};
};
sections = {
lualine_a = [ "mode" ];
lualine_b = [
"branch"
"diff"
"diagnostics"
];
lualine_c = [ "filename" ];
lualine_x = [
"encoding"
"fileformat"
"filetype"
];
lualine_y = [ "progress" ];
lualine_z = [ "location" ];
};
inactive_sections = {
lualine_a = [ ];
lualine_b = [ ];
lualine_c = [ "filename" ];
lualine_x = [ "location" ];
lualine_y = [ ];
lualine_z = [ ];
};
tabline = { };
winbar = { };
inactive_winbar = { };
extensions = { };
};
}
{
lazy = true;
dir = vPlug: vPlug.nvim-web-devicons;
}
];
}

77
services/nvim/model.nix Normal file
View file

@ -0,0 +1,77 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::model" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
short = "gsuuon/model.nvim";
cmd = [
"M"
"Model"
"Mchat"
];
init = ''
function()
vim.filetype.add({
extension = {
mchat = 'mchat',
}
})
end
'';
ft = [ "mchat" ];
keys = [
{
bind = "<C-m>d";
cmd = ":Mdelete<cr>";
opts = {
mode = "n";
};
}
{
bind = "<C-m>s";
cmd = ":Mselect<cr>";
opts = {
mode = "n";
};
}
{
bind = "<C-m><space>";
cmd = ":Mchat<cr>";
opts = {
mode = "n";
};
}
];
config = ''
function()
require('model.providers.llamacpp').setup({
binary = '/home/derped/.nix-profile/bin/llama-server',
models = '/home/derped/llama/models'
})
require('model').setup({
prompts = {
tower = {
provider = llamacpp,
options = {
model = 's',
args = {
'--keep', -1,
'-c', 8192,
'-ngl', 35
}
}
}
}
})
end
'';
}
];
}

50
services/nvim/noice.nix Normal file
View file

@ -0,0 +1,50 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::noice" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
dir = vPlug: vPlug.noice-nvim;
event = [ "VeryLazy" ];
dependencies =
vPlug: with vPlug; [
nui-nvim
nvim-notify
];
config = # lua
''
function()
require("noice").setup({
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp
},
},
-- you can enable a preset for easier configuration
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
-- command_palette = true, -- position the cmdline and popupmenu together
-- long_message_to_split = true, -- long messages will be sent to a split
-- inc_rename = false, -- enables an input dialog for inc-rename.nvim
-- lsp_doc_border = false, -- add a border to hover docs and signature help
},
})
end
'';
}
{
lazy = true;
dir = vPlug: vPlug.nvim-notify;
}
{
dir = vPlug: vPlug.dressing-nvim;
opts = { };
}
];
}

View file

@ -0,0 +1,27 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::nvim-highlight" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
dir = vPlug: vPlug.nvim-highlight-colors;
ft = [
"css"
"html"
"js"
"jsx"
"ts"
"tsx"
];
cmd = [ "HighlighColors" ];
opts = {
render = "virtual";
enable_tailwind = true;
};
}
];
}

View file

@ -0,0 +1,18 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::oil-nvim" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = false;
dir = vPlug: vPlug.oil-nvim;
opts = {
default_file_explorer = true;
delete_to_trash = true;
};
}
];
}

16
services/nvim/otter.nix Normal file
View file

@ -0,0 +1,16 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::otter" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
ft = [ ];
dir = vPlug: vPlug.otter-nvim;
opts = { };
}
];
}

View file

@ -0,0 +1,30 @@
{
lib,
config,
pkgs,
...
}:
lib.mkIf (lib.elem "nvim::render-markdown" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
dir = vPlug: vPlug.render-markdown-nvim;
dependencies = (
vPlug: with vPlug; [
nvim-web-devicons
"nvim-treesitter"
]
);
opts = {
completions = {
blink = {
enabled = (lib.elem "nvim::blink" config.machine.pkgs);
};
};
latex = {
converter = "${pkgs.python3Packages.pylatexenc}/bin/latex2text";
};
};
}
];
}

53
services/nvim/sniprun.nix Normal file
View file

@ -0,0 +1,53 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::sniprun" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
dir = vPlug: vPlug.sniprun;
ft = [
"md"
"adoc"
"org"
"go"
"py"
];
cmd = [ "SnipRun" ];
opts = {
live_mode_toggle = "enable";
# TODO: This does not work, maybe open an issue
# selected_interpreters = [ "Python3_fifo" ];
repl_enable = [ "Python3_original" ];
display = [ "TerminalWithCode" ];
};
keys = [
{
bind = "<leader>sr";
cmd = "<Plug>SnipRun";
opts = {
desc = "Run snippet.";
mode = [
"n"
"v"
];
};
}
{
bind = "<leader>sq";
cmd = "<Plug>SnipClose";
opts = {
desc = "Stop running interpreters.";
mode = [
"n"
"v"
];
};
}
];
}
];
}

View file

@ -0,0 +1,24 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::table-mode" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
dir = vPlug: vPlug.vim-table-mode;
cmd = [ "TableModeToggle" ];
keys = [
{
bind = "<leader>tm";
cmd = "<cmd>TableModeToggle<CR>";
opts = {
desc = "Toggle table mode";
};
}
];
}
];
}

View file

@ -0,0 +1,58 @@
{
lib,
config,
pkgs,
...
}:
lib.mkIf (lib.elem "nvim::telescope" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
dir = vPlug: vPlug.telescope-nvim;
dependencies = (
vPlug: with vPlug; [
plenary-nvim
"ghassan0/telescope-glyph.nvim"
"xiyaowong/telescope-emoji.nvim"
]
);
keys = [
{
bind = "<leader>ff";
cmd = "<Cmd>Telescope find_files<CR>";
opts = {
desc = "Telescope Find Files";
};
}
{
bind = "<leader>fg";
cmd = "<Cmd>Telescope git_files<CR>";
opts = {
desc = "Telescope Git Files";
};
}
{
bind = "<leader>fw";
cmd = "<Cmd>Telescope grep_string<CR>";
opts = {
desc = "Telescope Grep Cursor Word";
};
}
{
bind = "<leader>fr";
cmd = "<Cmd>Telescope live_grep<CR>";
opts = {
desc = "Telescope Grep Files";
};
}
];
}
{
dir = vPlug: vPlug.plenary-nvim;
lazy = true;
}
];
environment.systemPackages = [ pkgs.fd ];
}

View file

@ -0,0 +1,46 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::tmux-navigate" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
dir = vPlug: vPlug.vim-tmux-navigator;
cmd = [
"TmuxNavigateLeft"
"TmuxNavigateDown"
"TmuxNavigateUp"
"TmuxNavigateRight"
"TmuxNavigatePrevious"
];
keys = [
{
bind = "<M-h>";
cmd = "<Cmd>TmuxNavigateLeft<CR>";
}
{
bind = "<M-j>";
cmd = "<Cmd>TmuxNavigateDown<CR>";
}
{
bind = "<M-k>";
cmd = "<Cmd>TmuxNavigateUp<CR>";
}
{
bind = "<M-l>";
cmd = "<Cmd>TmuxNavigateRight<CR>";
}
{
bind = "<M-n>";
cmd = "<Cmd>TmuxNavigateNext<CR>";
}
{
bind = "<M-p>";
cmd = "<Cmd>TmuxNavigatePrevious<CR>";
}
];
}
];
}

View file

@ -0,0 +1,54 @@
{
lib,
config,
pkgs,
...
}:
lib.mkIf (lib.elem "nvim::treesitter" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins =
let
treesitter = pkgs.vimPlugins.nvim-treesitter.withAllGrammars;
grammars = pkgs.symlinkJoin {
name = "treesitter-parsers";
paths = treesitter.dependencies;
};
in
[
{
lazy = false;
dir = _: treesitter;
event = [
"BufReadPost"
"BufWritePost"
"BufNewFile"
"VeryLazy"
];
opts = {
auto_install = false;
highlight = {
enable = true;
};
incremental_selection = {
enable = true;
keymaps = {
init_selection = "gnn"; # set to `false` to disable one of the mappings
node_incremental = "grn";
scope_incremental = "grc";
node_decremental = "grm";
};
};
indent = {
enable = true;
};
};
config = # lua
''
function(_, opts)
vim.opt.rtp:prepend("${grammars}")
require("nvim-treesitter.configs").setup(opts)
end
'';
}
];
}

16
services/nvim/trim.nix Normal file
View file

@ -0,0 +1,16 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::trim" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
event = [ "BufWritePre" ];
dir = vPlug: vPlug.trim-nvim;
config = true;
}
];
}

View file

@ -0,0 +1,23 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::undotree" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
lazy = true;
dir = vPlug: vPlug.undotree;
keys = [
{
bind = "<leader>u";
cmd = "<Cmd>UndotreeToggle<CR>";
opts = {
desc = "Toggle Undotree";
};
}
];
}
];
}

View file

@ -0,0 +1,36 @@
{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::which-key" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
{
dir = vPlug: vPlug.which-key-nvim;
event = [ "VeryLazy" ];
keys = [
{
bind = "<leader>?";
cmdIsFunction = true;
cmd = # lua
''
function()
require("which-key").show({ global = false })
end
'';
opts = {
desc = "Buffer Local Keymaps (which-key)";
};
}
];
init = # lua
''
function()
vim.o.timeout = off
vim.o.ttimeout = off
end
'';
}
];
}