feat: language injections

This commit is contained in:
2024-06-10 18:30:00 +02:00
parent b24359b712
commit 552e85b6b6
10 changed files with 122 additions and 94 deletions

View File

@@ -22,7 +22,8 @@
}; };
}; };
programs.nixvim = { programs.nixvim = {
extraConfigLua = "if vim.g.neovide then vim.opt.linespace = -1 end"; extraConfigLua = # lua
"if vim.g.neovide then vim.opt.linespace = -1 end";
globals.neovide_cursor_vfx_mode = "pixiedust"; globals.neovide_cursor_vfx_mode = "pixiedust";
}; };
} }

View File

@@ -18,15 +18,16 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
userCommands.${cfg.commandName} = { userCommands.${cfg.commandName} = {
command = { command = {
__raw = '' __raw = # lua
function(args) ''
if args.bang then function(args)
vim.b.${cfg.varName} = not vim.b.${cfg.varName} if args.bang then
else vim.b.${cfg.varName} = not vim.b.${cfg.varName}
vim.g.${cfg.varName} = not vim.g.${cfg.varName} else
vim.g.${cfg.varName} = not vim.g.${cfg.varName}
end
end end
end '';
'';
}; };
}; };
@@ -54,14 +55,15 @@ in
}; };
}; };
conform-nvim.formatAfterSave = '' conform-nvim.formatAfterSave = # lua
function(bufnr) ''
if vim.g.${cfg.varName} or vim.b[bufnr].${cfg.varName} then function(bufnr)
return if vim.g.${cfg.varName} or vim.b[bufnr].${cfg.varName} then
return
end
return { timeout_ms = 500, lsp_fallback = true };
end end
return { timeout_ms = 500, lsp_fallback = true }; '';
end
'';
lualine.sections.lualine_x = lib.mkOrder 600 [ lualine.sections.lualine_x = lib.mkOrder 600 [
"(vim.g.${cfg.varName} or vim.b.${cfg.varName}) and '󱌓' or nil" "(vim.g.${cfg.varName} or vim.b.${cfg.varName}) and '󱌓' or nil"

View File

@@ -23,18 +23,19 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
extraConfigLua = '' extraConfigLua = # lua
function AutoSave() ''
if not vim.b.${cfg.varName} and not vim.g.${cfg.varName} then function AutoSave()
local bufnr = vim.api.nvim_get_current_buf() if not vim.b.${cfg.varName} and not vim.g.${cfg.varName} then
local modified = vim.api.nvim_buf_get_option(bufnr, 'modified') local bufnr = vim.api.nvim_get_current_buf()
if modified then local modified = vim.api.nvim_buf_get_option(bufnr, 'modified')
vim.cmd('silent! w') if modified then
print("Auto save at " .. os.date("%H:%M:%S")) vim.cmd('silent! w')
print("Auto save at " .. os.date("%H:%M:%S"))
end
end end
end end
end '';
'';
autoCmd = [ autoCmd = [
{ {
@@ -47,15 +48,16 @@ in
userCommands.${cfg.commandName} = { userCommands.${cfg.commandName} = {
bang = true; bang = true;
command = { command = {
__raw = '' __raw = # lua
function(args) ''
if args.bang then function(args)
vim.b.${cfg.varName} = not vim.b.${cfg.varName} if args.bang then
else vim.b.${cfg.varName} = not vim.b.${cfg.varName}
vim.g.${cfg.varName} = not vim.g.${cfg.varName} else
vim.g.${cfg.varName} = not vim.g.${cfg.varName}
end
end end
end '';
'';
}; };
}; };

View File

@@ -18,10 +18,14 @@ in
enable = true; enable = true;
settings = { settings = {
mapping = { mapping = {
"<C-n>" = "cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Select})"; "<C-n>" = # lua
"<C-p>" = "cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Select})"; "cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Select})";
"<C-Space>" = "cmp.mapping.confirm({select = true})"; "<C-p>" = # lua
"<C-Enter>" = "cmp.mapping.complete()"; "cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Select})";
"<C-Space>" = # lua
"cmp.mapping.confirm({select = true})";
"<C-Enter>" = # lua
"cmp.mapping.complete()";
}; };
sources = [ sources = [
{ name = "path"; } { name = "path"; }
@@ -34,7 +38,8 @@ in
"abbr" "abbr"
"kind" "kind"
]; ];
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; snippet.expand = # lua
"function(args) require('luasnip').lsp_expand(args.body) end";
window = { window = {
completion.border = "rounded"; completion.border = "rounded";
documentation.border = "rounded"; documentation.border = "rounded";

View File

@@ -13,36 +13,38 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
extraConfigLua = '' extraConfigLua = # lua
require("actions-preview").setup({}) ''
require("actions-preview").setup({})
local signs = { local signs = {
{ name = "DiagnosticSignError", text = "" }, { name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" }, { name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "󰌵" }, { name = "DiagnosticSignHint", text = "󰌵" },
{ name = "DiagnosticSignInfo", text = "" }, { name = "DiagnosticSignInfo", text = "" },
} }
for _, sign in ipairs(signs) do for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end end
vim.diagnostic.config({ vim.diagnostic.config({
virtual_text = true, virtual_text = true,
signs = true, signs = true,
underline = true, underline = true,
update_in_insert = true, update_in_insert = true,
severity_sort = false, severity_sort = false,
}) })
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
''; '';
keymaps = [ keymaps = [
{ {
key = "<leader>sa"; key = "<leader>sa";
mode = "n"; mode = "n";
options.silent = true; options.silent = true;
lua = true; lua = true;
action = "require('actions-preview').code_actions"; action = # lua
"require('actions-preview').code_actions";
} }
{ {
key = "<leader>sx"; key = "<leader>sx";

View File

@@ -8,11 +8,18 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
opts.showmode = false;
plugins = { plugins = {
notify = { notify = {
enable = true; enable = true;
backgroundColour = "#000000"; stages = "static";
}; };
telescope = {
enable = true;
keymaps."<leader>n" = # vim
"notify";
};
which-key.registrations."<leader>n" = "Notifications";
lualine = { lualine = {
enable = true; enable = true;
globalstatus = true; globalstatus = true;

View File

@@ -23,11 +23,12 @@ in
filteredItems.visible = true; filteredItems.visible = true;
}; };
popupBorderStyle = "rounded"; popupBorderStyle = "rounded";
eventHandlers.file_opened = '' eventHandlers.file_opened = # lua
function() ''
require('neo-tree').close_all() function()
end require('neo-tree').close_all()
''; end
'';
}; };
which-key.registrations."<leader>f".t = "Tree"; which-key.registrations."<leader>f".t = "Tree";
}; };

View File

@@ -21,33 +21,35 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
extraConfigLua = '' extraConfigLua = # lua
LazygitTerminal = require("toggleterm.terminal").Terminal:new({ ''
cmd = "${lib.getExe pkgs.lazygit}", LazygitTerminal = require("toggleterm.terminal").Terminal:new({
dir = "git_dir", cmd = "${lib.getExe pkgs.lazygit}",
direction = "float", dir = "git_dir",
direction = "float",
on_open = function(term) on_open = function(term)
vim.cmd("startinsert!") vim.cmd("startinsert!")
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true }) vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
end, end,
on_close = function(_) on_close = function(_)
vim.cmd("startinsert!") vim.cmd("startinsert!")
end, end,
}) })
function LazygitToggle() function LazygitToggle()
lazygit:toggle() lazygit:toggle()
end end
''; '';
userCommands.${cfg.commandName} = { userCommands.${cfg.commandName} = {
command = { command = {
__raw = '' __raw = # lua
function() ''
LazygitTerminal:toggle() function()
end LazygitTerminal:toggle()
''; end
'';
}; };
}; };

View File

@@ -13,31 +13,36 @@ in
key = "<leader>xx"; key = "<leader>xx";
mode = "n"; mode = "n";
lua = true; lua = true;
action = "require('trouble').toggle"; action = # lua
"require('trouble').toggle";
} }
{ {
key = "<leader>xw"; key = "<leader>xw";
mode = "n"; mode = "n";
lua = true; lua = true;
action = "function() require('trouble').toggle('workspace_diagnostics') end"; action = # lua
"function() require('trouble').toggle('workspace_diagnostics') end";
} }
{ {
key = "<leader>xd"; key = "<leader>xd";
mode = "n"; mode = "n";
lua = true; lua = true;
action = "function() require('trouble').toggle('document_diagnostics') end"; action = # lua
"function() require('trouble').toggle('document_diagnostics') end";
} }
{ {
key = "<leader>xq"; key = "<leader>xq";
mode = "n"; mode = "n";
lua = true; lua = true;
action = "function() require('trouble').toggle('quickfix') end"; action = # lua
"function() require('trouble').toggle('quickfix') end";
} }
{ {
key = "<leader>xl"; key = "<leader>xl";
mode = "n"; mode = "n";
lua = true; lua = true;
action = "function() require('trouble').toggle('loclist') end"; action = # lua
"function() require('trouble').toggle('loclist') end";
} }
]; ];
plugins = { plugins = {

View File

@@ -10,7 +10,8 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
opts = { opts = {
undodir = { undodir = {
__raw = "os.getenv('HOME') .. '/.config/nvim/undodir'"; __raw = # lua
"os.getenv('HOME') .. '/.config/nvim/undodir'";
}; };
undofile = true; undofile = true;
}; };