module resyntaxing

This commit is contained in:
cnst
2024-08-31 20:24:08 +02:00
parent b721c5cc25
commit 1beecf1d99
34 changed files with 1567 additions and 438 deletions

View File

@@ -1,51 +1,148 @@
{
programs.nixvim = {
opts.completeopt = ["menu" "menuone" "noselect"];
plugins = {
luasnip.enable = true;
lspkind = {
enable = true;
cmp = {
enable = true;
menu = {
nvim_lsp = "[LSP]";
nvim_lua = "[api]";
path = "[path]";
luasnip = "[snip]";
buffer = "[buffer]";
};
};
};
cmp-buffer = {enable = true;};
cmp-emoji = {enable = true;};
cmp-nvim-lsp = {enable = true;};
cmp-path = {enable = true;};
cmp_luasnip = {enable = true;};
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 })";
};
experimental = {ghost_text = true;};
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';
sources = [
{name = "path";}
{name = "nvim_lsp";}
{name = "luasnip";}
{
name = "buffer";
# Words from other open buffers can also be suggested.
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
}
{name = "nvim_lua";}
{name = "path";}
{name = "copilot";}
];
formatting = {
fields = ["abbr" "kind" "menu"];
format =
# lua
''
function(_, item)
local icons = {
Namespace = "󰌗",
Text = "󰉿",
Method = "󰆧",
Function = "󰆧",
Constructor = "",
Field = "󰜢",
Variable = "󰀫",
Class = "󰠱",
Interface = "",
Module = "",
Property = "󰜢",
Unit = "󰑭",
Value = "󰎠",
Enum = "",
Keyword = "󰌋",
Snippet = "",
Color = "󰏘",
File = "󰈚",
Reference = "󰈇",
Folder = "󰉋",
EnumMember = "",
Constant = "󰏿",
Struct = "󰙅",
Event = "",
Operator = "󰆕",
TypeParameter = "󰊄",
Table = "",
Object = "󰅩",
Tag = "",
Array = "[]",
Boolean = "",
Number = "",
Null = "󰟢",
String = "󰉿",
Calendar = "",
Watch = "󰥔",
Package = "",
Copilot = "",
Codeium = "",
TabNine = "",
}
local icon = icons[item.kind] or ""
item.kind = string.format("%s %s", icon, item.kind or "")
return item
end
'';
};
window = {
completion = {
winhighlight = "FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel";
scrollbar = false;
sidePadding = 0;
border = ["" "" "" "" "" "" "" ""];
};
settings.documentation = {
border = ["" "" "" "" "" "" "" ""];
winhighlight = "FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel";
};
};
mapping = {
"<C-l>" = "cmp.mapping.select_prev_item()";
"<C-ä>" = "cmp.mapping.select_next_item()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<S-Tab>" = "cmp.mapping.close()";
"<Tab>" =
# lua
''
function(fallback)
local line = vim.api.nvim_get_current_line()
if line:match("^%s*$") then
fallback()
elseif cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })
else
fallback()
end
end
'';
"<Down>" =
# lua
''
function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end
'';
"<Up>" =
# lua
''
function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
else
fallback()
end
end
'';
};
};
};
};

View File

@@ -12,7 +12,6 @@ in {
inputs.nixvim.homeManagerModules.nixvim
./plugins
./autocmd.nix
./completion.nix
./keymap.nix
./options.nix
./todo.nix
@@ -24,7 +23,7 @@ in {
config = mkIf cfg.enable {
programs.nixvim = {
extraPlugins = [pkgs.vimPlugins.gruvbox-material];
extraPlugins = with pkgs.vimPlugins; [gruvbox-material-nvim nvim-web-devicons];
colorscheme = "gruvbox-material";
enable = true;
defaultEditor = true;
@@ -32,13 +31,8 @@ in {
vimAlias = true;
luaLoader.enable = true;
plugins = {
gitsigns = {
enable = true;
settings.signs = {
add.text = "+";
change.text = "~";
};
};
gitsigns.enable = true;
statuscol.enable = true;
nvim-autopairs.enable = true;
nvim-colorizer = {
enable = true;

View File

@@ -0,0 +1,163 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.cmp;
in {
options = {
modules.devtools.nixvim.plugins.cmp.enable = mkEnableOption "Enables completion plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim = {
plugins = {
luasnip.enable = true;
cmp-buffer = {enable = true;};
cmp-emoji = {enable = true;};
cmp-nvim-lsp = {enable = true;};
cmp-path = {enable = true;};
cmp_luasnip = {enable = true;};
cmp = {
enable = true;
settings = {
experimental = {ghost_text = true;};
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';
sources = [
{name = "nvim_lsp";}
{name = "luasnip";}
{
name = "buffer";
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
}
{name = "nvim_lua";}
{name = "path";}
{name = "copilot";}
];
formatting = {
fields = ["abbr" "kind" "menu"];
format =
# lua
''
function(_, item)
local icons = {
Namespace = "󰌗",
Text = "󰉿",
Method = "󰆧",
Function = "󰆧",
Constructor = "",
Field = "󰜢",
Variable = "󰀫",
Class = "󰠱",
Interface = "",
Module = "",
Property = "󰜢",
Unit = "󰑭",
Value = "󰎠",
Enum = "",
Keyword = "󰌋",
Snippet = "",
Color = "󰏘",
File = "󰈚",
Reference = "󰈇",
Folder = "󰉋",
EnumMember = "",
Constant = "󰏿",
Struct = "󰙅",
Event = "",
Operator = "󰆕",
TypeParameter = "󰊄",
Table = "",
Object = "󰅩",
Tag = "",
Array = "[]",
Boolean = "",
Number = "",
Null = "󰟢",
String = "󰉿",
Calendar = "",
Watch = "󰥔",
Package = "",
Copilot = "",
Codeium = "",
TabNine = "",
}
local icon = icons[item.kind] or ""
item.kind = string.format("%s %s", icon, item.kind or "")
return item
end
'';
};
window = {
completion = {
winhighlight = "FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel";
scrollbar = false;
sidePadding = 0;
border = ["" "" "" "" "" "" "" ""];
};
settings.documentation = {
border = ["" "" "" "" "" "" "" ""];
winhighlight = "FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel";
};
};
mapping = {
"<C-l>" = "cmp.mapping.select_prev_item()";
"<C-ä>" = "cmp.mapping.select_next_item()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<S-Tab>" = "cmp.mapping.close()";
"<Tab>" =
# lua
''
function(fallback)
local line = vim.api.nvim_get_current_line()
if line:match("^%s*$") then
fallback()
elseif cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })
else
fallback()
end
end
'';
"<Down>" =
# lua
''
function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end
'';
"<Up>" =
# lua
''
function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
else
fallback()
end
end
'';
};
};
};
};
};
};
}

View File

@@ -1,35 +1,44 @@
{
lib,
config,
pkgs,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.conform-nvim;
cfg = config.modules.devtools.nixvim.plugins.conform;
in {
options = {
modules.devtools.nixvim.plugins.conform-nvim.enable = mkEnableOption "Enables Conform plugin for nixvim";
modules.devtools.nixvim.plugins.conform.enable = mkEnableOption "Enables Conform plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.conform-nvim = {
programs.nixvim.plugins.conform = {
enable = true;
settings = {
notify_on_error = true;
formatters_by_ft = {
liquidsoap = ["liquidsoap-prettier"];
html = [["prettierd" "prettier"]];
css = [["prettierd" "prettier"]];
javascript = [["prettierd" "prettier"]];
javascriptreact = [["prettierd" "prettier"]];
typescript = [["prettierd" "prettier"]];
typescriptreact = [["prettierd" "prettier"]];
html = ["prettierd" "prettier"];
css = ["prettierd" "prettier"];
javascript = ["prettierd" "prettier"];
javascriptreact = ["prettierd" "prettier"];
typescript = ["prettierd" "prettier"];
typescriptreact = ["prettierd" "prettier"];
python = ["black"];
lua = ["stylua"];
nix = ["alejandra"];
markdown = [["prettierd" "prettier"]];
yaml = ["yamllint" "yamlfmt"];
markdown = ["prettierd" "prettier"];
yaml = ["yamlfmt"];
rust = ["rustfmt"];
xml = ["xmllint"];
php = ["php-cs-fixer"];
};
stop_after_first = true;
};
};
home.packages = with pkgs; [
prettierd
yamlfmt
libxml2Python
];
};
}

View File

@@ -19,11 +19,11 @@ in {
copilot-lua = {
enable = true;
suggestion = {
enabled = true;
enabled = false;
autoTrigger = true;
keymap.accept = "<C-CR>";
};
panel.enabled = true;
panel.enabled = false;
};
};
keymaps = [

View File

@@ -3,12 +3,14 @@
"${userModules}/devtools/nixvim/plugins/barbar.nix"
"${userModules}/devtools/nixvim/plugins/comment.nix"
"${userModules}/devtools/nixvim/plugins/conform.nix"
"${userModules}/devtools/nixvim/plugins/cmp.nix"
"${userModules}/devtools/nixvim/plugins/copilot.nix"
"${userModules}/devtools/nixvim/plugins/efm.nix"
"${userModules}/devtools/nixvim/plugins/floaterm.nix"
"${userModules}/devtools/nixvim/plugins/harpoon.nix"
"${userModules}/devtools/nixvim/plugins/lsp.nix"
"${userModules}/devtools/nixvim/plugins/lualine.nix"
"${userModules}/devtools/nixvim/plugins/lightline.nix"
"${userModules}/devtools/nixvim/plugins/markdown-preview.nix"
"${userModules}/devtools/nixvim/plugins/neo-tree.nix"
"${userModules}/devtools/nixvim/plugins/nonels.nix"

View File

@@ -67,6 +67,7 @@ in {
formatter = "black";
};
nix = {
formatter = "alejandra";
linter = "statix";
};
lua = {
@@ -86,12 +87,24 @@ in {
css = {
formatter = "prettier";
};
scss = {
formatter = "prettier";
};
ts = {
formatter = "prettier";
};
gitcommit = {
linter = "gitlint";
};
php = {
formatter = "php_cs_fixer";
};
rust = {
formatter = "rustfmt";
};
sql = {
formatter = "sql-formatter";
};
};
};
};

View File

@@ -0,0 +1,51 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.lightline;
in {
options = {
modules.devtools.nixvim.plugins.lightline.enable = mkEnableOption "Enables lightline plugin for nixvim";
};
config = mkIf cfg.enable {
programs.nixvim.plugins.lightline = {
enable = true;
settings = {
colorscheme = "apprentice";
active = {
right = [
[
"lineinfo"
]
[
"percent"
]
[
"fileformat"
"fileencoding"
"filetype"
]
];
};
component = {
charvaluehex = "0x%B";
lineinfo = "%3l:%-2v%<";
};
component_function = {
gitbranch = "FugitiveHead";
};
inactive = [];
mode_map = {
"<C-s>" = "SB";
"<C-v>" = "VB";
i = "I";
n = "N";
v = "V";
};
};
};
};
}

View File

@@ -0,0 +1,32 @@
{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.devtools.nixvim.plugins.lsp-format;
in {
options = {
modules.devtools.nixvim.plugins.lsp-format = {
enable = mkEnableOption "Enables LSP formatting support for nixvim";
};
};
config = mkIf cfg.enable {
programs.nixvim.plugins.lsp-format = {
enable = true;
lspServersToEnable = [
"rustfmt"
"prettier"
"prettierd"
"php-cs-fixer"
"alejandra"
"xmllint"
"black"
"yamlfmt"
"stylua"
];
};
};
}

View File

@@ -13,54 +13,62 @@ in {
};
config = mkIf cfg.enable {
programs.nixvim.plugins.lsp = {
enable = true;
keymaps = {
silent = true;
diagnostic = {
"<leader>k" = "goto_prev";
"<leader>j" = "goto_next";
};
lspBuf = {
gd = "definition";
gD = "references";
gt = "type_definition";
gi = "implementation";
K = "hover";
"<F2>" = "rename";
};
programs.nixvim.plugins = {
lsp-format = {
enable = true;
lspServersToEnable = [
"rust-analyzer"
];
};
lsp = {
enable = true;
servers = {
# Average webdev LSPs
cssls.enable = true; # CSS
tailwindcss.enable = true; # TailwindCSS
html.enable = true; # HTML
astro.enable = true; # AstroJS
phpactor.enable = true; # PHP
svelte.enable = false; # Svelte
vuels.enable = false; # Vue
pyright.enable = true;
marksman.enable = true;
nixd.enable = true;
dockerls.enable = true;
bashls.enable = true;
clangd.enable = true;
csharp-ls.enable = true;
yamlls.enable = true;
lua-ls = {
enable = true;
settings = {
telemetry.enable = false;
diagnostics = {
globals = ["vim"];
};
keymaps = {
silent = true;
diagnostic = {
"<leader>k" = "goto_prev";
"<leader>j" = "goto_next";
};
lspBuf = {
gd = "definition";
gD = "references";
gt = "type_definition";
gi = "implementation";
K = "hover";
"<F2>" = "rename";
};
};
tsserver = {
enable = false; # TS/JS
servers = {
# Average webdev LSPs
cssls.enable = true; # CSS
tailwindcss.enable = true; # TailwindCSS
html.enable = true; # HTML
astro.enable = true; # AstroJS
phpactor.enable = true; # PHP
svelte.enable = false; # Svelte
vuels.enable = false; # Vue
pyright.enable = true;
marksman.enable = true;
nixd.enable = true;
dockerls.enable = true;
bashls.enable = true;
clangd.enable = true;
csharp-ls.enable = true;
yamlls.enable = true;
lua-ls = {
enable = true;
settings = {
telemetry.enable = false;
diagnostics = {
globals = ["vim"];
};
};
};
tsserver = {
enable = false; # TS/JS
};
};
};
};

View File

@@ -31,22 +31,35 @@ in {
local msg = ""
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then
return msg
end
local non_null_ls_clients = {}
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
if client.name ~= "null-ls" then
table.insert(non_null_ls_clients, client)
end
end
if #non_null_ls_clients > 0 then
for _, client in ipairs(non_null_ls_clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
else
for _, client in ipairs(clients) do
if client.name == "null-ls" then
return client.name
end
end
end
return msg
end
'';
icon = "";
color.fg = "#ffffff";
color.fg = "#A89984";
}
"encoding"
"fileformat"
"filetype"
];

View File

@@ -7,7 +7,7 @@
cfg = config.modules.devtools.nixvim.plugins.neo-tree;
in {
options = {
modules.devtools.nixvim.plugins.neo-tree.enable = mkEnableOption "Enables nix-tree plugin for nixvim";
modules.devtools.nixvim.plugins.neo-tree.enable = mkEnableOption "Enables neo-tree plugin for nixvim";
};
config = mkIf cfg.enable {
@@ -18,7 +18,7 @@ in {
closeIfLastWindow = true;
window = {
width = 30;
autoExpandWidth = true;
# autoExpandWidth = true;
};
};
@@ -26,7 +26,7 @@ in {
{
mode = "n";
key = "<leader>n";
action = ":neotree action=focus reveal toggle<CR>";
action = ":Neotree focus toggle<CR>";
options.silent = true;
}
];

View File

@@ -32,12 +32,15 @@ in {
alejandra.enable = true;
stylua.enable = true;
shfmt.enable = true;
nixpkgs_fmt.enable = false;
google_java_format.enable = false;
prettier = {
enable = true;
disableTsServerFormatter = true;
};
prettierd.enable = true;
phpcsfixer.enable = true;
xmllint.enable = true;
yamlfmt.enable = true;
black = {
enable = true;
settings = ''

View File

@@ -1,6 +1,5 @@
{
lib,
pkgs,
config,
...
}:
@@ -13,8 +12,17 @@ in {
config = mkIf cfg.enable {
programs.nixvim = {
plugins = {
rustaceanvim.enable = true;
plugins.rustaceanvim = {
enable = true;
settings.server = {
default_settings.rust-analyzer = {
cargo.features = "all";
checkOnSave = true;
check.command = "clippy";
rustc.source = "discover";
};
};
};
};
};