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

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

View File

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

View File

@@ -18,10 +18,14 @@ in
enable = true;
settings = {
mapping = {
"<C-n>" = "cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Select})";
"<C-p>" = "cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Select})";
"<C-Space>" = "cmp.mapping.confirm({select = true})";
"<C-Enter>" = "cmp.mapping.complete()";
"<C-n>" = # lua
"cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Select})";
"<C-p>" = # lua
"cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Select})";
"<C-Space>" = # lua
"cmp.mapping.confirm({select = true})";
"<C-Enter>" = # lua
"cmp.mapping.complete()";
};
sources = [
{ name = "path"; }
@@ -34,7 +38,8 @@ in
"abbr"
"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 = {
completion.border = "rounded";
documentation.border = "rounded";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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