feat: add lazy loading to nvim
This commit is contained in:
parent
6ebfb3d109
commit
752dfc55e8
64 changed files with 68 additions and 1265 deletions
|
|
@ -6,7 +6,7 @@ let
|
||||||
cfg = config.my.programs.nvim;
|
cfg = config.my.programs.nvim;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = lib.my.listModulesRec ./new_plugins;
|
imports = lib.my.listModulesRec ./plugins;
|
||||||
|
|
||||||
options.my.programs.nvim.enable = mkEnableOption "nvim";
|
options.my.programs.nvim.enable = mkEnableOption "nvim";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
_:
|
|
||||||
|
|
||||||
{
|
|
||||||
home-manager.users.moritz.programs.nixvim = {
|
|
||||||
plugins.otter.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
{ config, lib, pkgs, inputs, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (lib) mkEnableOption mkIf readFile;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
home-manager.users.moritz.programs.nixvim = {
|
|
||||||
plugins.render-markdown = {
|
|
||||||
enable = true;
|
|
||||||
settings.latex.enable = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
{ config, lib, pkgs, inputs, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (lib) mkEnableOption mkIf readFile;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
home-manager.users.moritz.programs.nixvim = {
|
|
||||||
plugins.treesitter = {
|
|
||||||
enable = true;
|
|
||||||
folding = true;
|
|
||||||
nixvimInjections = true;
|
|
||||||
settings.indent.enable = true;
|
|
||||||
settings.highlight.enable = true;
|
|
||||||
settings.incremental_selection = {
|
|
||||||
enable = true;
|
|
||||||
keymaps.init_selection = "gn";
|
|
||||||
keymaps.node_decremental = "gp";
|
|
||||||
keymaps.node_incremental = "gn";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
performance.combinePlugins.standalonePlugins = [
|
|
||||||
"nvim-treesitter"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -23,6 +23,7 @@ in
|
||||||
api_key_name = "cmd:cat /run/agenix/openai";
|
api_key_name = "cmd:cat /run/agenix/openai";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
lazyLoad.settings.event = [ "DeferredUIEnter" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
|
|
@ -1,233 +0,0 @@
|
||||||
{ pkgs, lib, inputs, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (builtins) readFile;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
config.home-manager.users.moritz.programs.neovim.lazy.plugins = [
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.oil-nvim;
|
|
||||||
lazy = false;
|
|
||||||
opts = { };
|
|
||||||
dependencies = [{ plugin = pkgs.vimPlugins.nvim-web-devicons; }];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.lualine-nvim;
|
|
||||||
opts = { };
|
|
||||||
dependencies = [{ plugin = pkgs.vimPlugins.nvim-web-devicons; }];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.mini-nvim;
|
|
||||||
lazy = false;
|
|
||||||
conf = readFile ./lua/mini-nvim.lua;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.nvim-cmp;
|
|
||||||
keys = [
|
|
||||||
{ key = "<leader>tc"; cmd = "<cmd>CmpToggle<cr>"; desc = "Toggle Cmp sources"; }
|
|
||||||
];
|
|
||||||
conf = readFile ./lua/nvim-cmp.lua;
|
|
||||||
event = [ "InsertEnter" ];
|
|
||||||
dependencies = [
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.nvim-autopairs;
|
|
||||||
opts = { };
|
|
||||||
}
|
|
||||||
{ plugin = pkgs.vimPlugins.cmp-async-path; }
|
|
||||||
{ plugin = pkgs.vimPlugins.cmp-buffer; }
|
|
||||||
{ plugin = pkgs.vimPlugins.cmp-cmdline; }
|
|
||||||
{ plugin = pkgs.vimPlugins.cmp-nvim-lsp-signature-help; }
|
|
||||||
{ plugin = pkgs.vimPlugins.cmp-nvim-lsp; }
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimUtils.buildVimPlugin {
|
|
||||||
pname = "cmp-vimtex";
|
|
||||||
version = lib.my.mkVersionInput inputs.cmp-vimtex;
|
|
||||||
src = inputs.cmp-vimtex;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
{ plugin = pkgs.vimPlugins.cmp_luasnip; }
|
|
||||||
# {
|
|
||||||
# plugin = pkgs.vimPlugins.copilot-cmp;
|
|
||||||
# opts = { };
|
|
||||||
# dependencies = [
|
|
||||||
# {
|
|
||||||
# plugin = pkgs.vimPlugins.copilot-lua;
|
|
||||||
# opts = {
|
|
||||||
# suggestion = { enabled = false; };
|
|
||||||
# panel = { enabled = false; };
|
|
||||||
# };
|
|
||||||
# conf = /* lua */ ''
|
|
||||||
# require("copilot").setup(opts)
|
|
||||||
# vim.cmd("Copilot disable")
|
|
||||||
# '';
|
|
||||||
# }
|
|
||||||
# ];
|
|
||||||
# }
|
|
||||||
{ plugin = pkgs.vimPlugins.friendly-snippets; }
|
|
||||||
{ plugin = pkgs.vimPlugins.lspkind-nvim; }
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.luasnip;
|
|
||||||
conf = readFile ./lua/luasnip.lua;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.direnv-vim;
|
|
||||||
lazy = false;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.nvim-lspconfig.overrideAttrs (_: {
|
|
||||||
version = lib.my.mkVersionInput inputs.nvim-lspconfig;
|
|
||||||
src = inputs.nvim-lspconfig;
|
|
||||||
});
|
|
||||||
event = [ "BufRead" "BufNewFile" ];
|
|
||||||
conf = readFile ./lua/nvim-lspconfig.lua;
|
|
||||||
dependencies = [
|
|
||||||
{
|
|
||||||
# TODO: add all required tools to neovim or silence warnings
|
|
||||||
plugin = pkgs.vimPlugins.none-ls-nvim;
|
|
||||||
conf = readFile ./lua/null-ls-nvim.lua;
|
|
||||||
dependencies = [
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimUtils.buildVimPlugin {
|
|
||||||
pname = "none-ls-shellcheck.nvim";
|
|
||||||
version = lib.my.mkVersionInput inputs.none-ls-shellcheck-nvim;
|
|
||||||
src = inputs.none-ls-shellcheck-nvim;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{ plugin = pkgs.vimPlugins.lsp_lines-nvim; }
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.inc-rename-nvim;
|
|
||||||
opts = {
|
|
||||||
input_buffer_type = "dressing";
|
|
||||||
};
|
|
||||||
dependencies = [
|
|
||||||
{ plugin = pkgs.vimPlugins.dressing-nvim; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimUtils.buildVimPlugin {
|
|
||||||
pname = "actions-preview-nvim";
|
|
||||||
version = lib.my.mkVersionInput inputs.actions-preview-nvim;
|
|
||||||
src = inputs.actions-preview-nvim;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.vim-fugitive;
|
|
||||||
cmd = [
|
|
||||||
"G"
|
|
||||||
"Git"
|
|
||||||
"Ggrep"
|
|
||||||
"Glgrep"
|
|
||||||
"Gclog"
|
|
||||||
"Gllog"
|
|
||||||
"Gcd"
|
|
||||||
"Glcd"
|
|
||||||
"Gedit"
|
|
||||||
"Gsplit"
|
|
||||||
"Gvsplit"
|
|
||||||
"Gtabedit"
|
|
||||||
"Gpedit"
|
|
||||||
"Gdrop"
|
|
||||||
"Gread"
|
|
||||||
"Gwrite"
|
|
||||||
"Gwq"
|
|
||||||
"Gdiffsplit"
|
|
||||||
"Gvdiffsplit"
|
|
||||||
"GMove"
|
|
||||||
"GRename"
|
|
||||||
"GDelete"
|
|
||||||
"GBrowse"
|
|
||||||
];
|
|
||||||
keys = [
|
|
||||||
{ key = "<leader>gg"; cmd = "<cmd>Gedit :<cr>"; desc = "Open Status"; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.vim-tmux-navigator;
|
|
||||||
event = [ "VeryLazy" ];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.nvim-lastplace;
|
|
||||||
event = [ "BufReadPost" "BufNewFile" ];
|
|
||||||
opts = {
|
|
||||||
lastplace_ignore_buftype = [ "quickfix" "nofile" "help" ];
|
|
||||||
lastplace_ignore_filetype = [ "gitcommit" "gitrebase" "svn" "hgcommit" ];
|
|
||||||
lastplace_open_folds = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.telescope-nvim;
|
|
||||||
cmd = [ "Telescope" ];
|
|
||||||
conf = builtins.readFile ./lua/telescope.lua;
|
|
||||||
keys = [
|
|
||||||
{ key = "<leader>ff"; cmd = "<cmd>Telescope find_files<cr>"; desc = "Find files"; }
|
|
||||||
{ key = "<leader>fb"; cmd = "<cmd>Telescope buffers<cr>"; desc = "Find buffers"; }
|
|
||||||
{ key = "<leader>fl"; cmd = "<cmd>Telescope current_buffer_fuzzy_find<cr>"; desc = "Search lines"; }
|
|
||||||
{
|
|
||||||
key = "<leader>fl";
|
|
||||||
cmd = "y<ESC>:Telescope current_buffer_fuzzy_find default_text=<c-r>0<CR>";
|
|
||||||
desc = "Search lines (selection)";
|
|
||||||
mode = [ "v" ];
|
|
||||||
}
|
|
||||||
{ key = "<leader>fg"; cmd = "<cmd>Telescope live_grep<cr>"; desc = "Live grep"; }
|
|
||||||
{
|
|
||||||
key = "<leader>fg";
|
|
||||||
cmd = "y<ESC>:Telescope live_grep default_text=<c-r>0<CR>";
|
|
||||||
desc = "Live grep (selection)";
|
|
||||||
mode = [ "v" ];
|
|
||||||
}
|
|
||||||
{ key = "<leader>fh"; cmd = "<cmd>Telescope help_tags<cr>"; desc = "Help tags"; }
|
|
||||||
{ key = "<leader>fr"; cmd = "<cmd>Telescope oldfiles<cr>"; desc = "Recent files"; }
|
|
||||||
];
|
|
||||||
dependencies = [
|
|
||||||
{ plugin = pkgs.vimPlugins.plenary-nvim; }
|
|
||||||
{ plugin = pkgs.vimPlugins.telescope-fzf-native-nvim; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.vim-startuptime;
|
|
||||||
cmd = [ "StartupTime" ];
|
|
||||||
conf = readFile ./lua/vim-startuptime.lua;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.typst-vim;
|
|
||||||
ft = [ "typst" "typ" ];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.comment-nvim;
|
|
||||||
event = [ "BufReadPost" "BufNewFile" ];
|
|
||||||
opts = { };
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.nvim-surround;
|
|
||||||
event = [ "BufReadPost" "BufNewFile" ];
|
|
||||||
opts = { };
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.conform-nvim;
|
|
||||||
keys = [
|
|
||||||
{ key = "="; cmd = "<cmd>lua require('conform').format()<cr>"; desc = "format buffer"; mode = [ "n" "v" ]; }
|
|
||||||
];
|
|
||||||
cmd = [ "ConformInfo" "Format" ];
|
|
||||||
conf = readFile ./lua/conform.lua;
|
|
||||||
}
|
|
||||||
{ plugin = pkgs.vimPlugins.plantuml-syntax; }
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.vimtex;
|
|
||||||
lazy = false;
|
|
||||||
conf = /* lua */ ''
|
|
||||||
vim.g.vimtex_view_method = "zathura"
|
|
||||||
vim.g.vimtex_mappings_disable = vim.fn.executable("texlab") == 1 and { ["n"] = { "K" } } or {} -- disable `K` as it conflicts with LSP hover if texlab is in path
|
|
||||||
vim.g.vimtex_quickfix_method = vim.fn.executable("pplatex") == 1 and "pplatex" or "latexlog"
|
|
||||||
'';
|
|
||||||
keys = [
|
|
||||||
{ key = "<localleader>l"; cmd = ""; desc = "+vimtex"; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -6,5 +6,6 @@ in
|
||||||
{
|
{
|
||||||
home-manager.users.moritz.programs.nixvim = {
|
home-manager.users.moritz.programs.nixvim = {
|
||||||
plugins.crates.enable = true;
|
plugins.crates.enable = true;
|
||||||
|
plugins.crates.lazyLoad.settings.event = [ "BufRead Cargo.toml" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
{ pkgs, lib, ... }:
|
|
||||||
|
|
||||||
with builtins;
|
|
||||||
{
|
|
||||||
config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
|
|
||||||
{
|
|
||||||
plugin = nvim-dap;
|
|
||||||
keys = [
|
|
||||||
{ key = "<leader>cb"; cmd = "<cmd>lua require('dap').toggle_breakpoint()<cr>"; desc = "Toggle breakpoint"; }
|
|
||||||
{ key = "<leader>cd"; cmd = "<cmd>lua require('dap').continue()<cr>"; desc = "Continue"; }
|
|
||||||
];
|
|
||||||
dependencies = [
|
|
||||||
{
|
|
||||||
plugin = nvim-dap-python;
|
|
||||||
ft = [ "python" ];
|
|
||||||
conf =
|
|
||||||
let
|
|
||||||
pythonWithDebugpy = pkgs.python3.withPackages (ps: with ps; [ debugpy ]);
|
|
||||||
in
|
|
||||||
/* lua */ ''
|
|
||||||
require("dap-python").setup("${lib.getExe pythonWithDebugpy}")
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = nvim-dap-virtual-text;
|
|
||||||
opts = { };
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = nvim-dap-ui;
|
|
||||||
opts = { };
|
|
||||||
conf = /* lua */ ''
|
|
||||||
local dap = require("dap")
|
|
||||||
local dapui = require("dapui")
|
|
||||||
dapui.setup(opts)
|
|
||||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
|
||||||
dapui.open({})
|
|
||||||
end
|
|
||||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
|
||||||
dapui.close({})
|
|
||||||
end
|
|
||||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
|
||||||
dapui.close({})
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
require("catppuccin").setup({
|
|
||||||
compile_path = vim.fn.stdpath("cache") .. "/catppuccin", -- fix issue of writing to nix store
|
|
||||||
integrations = {
|
|
||||||
gitsigns = true,
|
|
||||||
lsp_saga = true,
|
|
||||||
mini = true,
|
|
||||||
noice = true,
|
|
||||||
cmp = true,
|
|
||||||
native_lsp = {
|
|
||||||
enabled = true,
|
|
||||||
},
|
|
||||||
treesitter = true,
|
|
||||||
telekasten = true,
|
|
||||||
telescope = true,
|
|
||||||
lsp_trouble = true,
|
|
||||||
which_key = true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
vim.cmd.colorscheme("catppuccin-macchiato")
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
local conform = require("conform")
|
|
||||||
|
|
||||||
local formatters_by_ft = {
|
|
||||||
["*"] = { "codespell", "trim_whitespace" },
|
|
||||||
elixir = { "mix" },
|
|
||||||
gleam = { "gleam" },
|
|
||||||
go = { "gofmt" },
|
|
||||||
json = { "jq" },
|
|
||||||
lua = { "stylua" },
|
|
||||||
nix = { { "nixpkgs_fmt", "alejandra" } },
|
|
||||||
python = { { "ruff_fix", "isort" }, { "ruff_format", "black" } },
|
|
||||||
rust = { "rustfmt" },
|
|
||||||
sh = { "shfmt" },
|
|
||||||
tex = { "latexindent" },
|
|
||||||
toml = { "taplo" },
|
|
||||||
yaml = { "yamlfix" },
|
|
||||||
}
|
|
||||||
|
|
||||||
conform.setup({
|
|
||||||
formatters_by_ft = formatters_by_ft,
|
|
||||||
formatters = {
|
|
||||||
gleam = {
|
|
||||||
command = "gleam",
|
|
||||||
args = { "format", "--stdin" },
|
|
||||||
stdin = true,
|
|
||||||
cwd = require("conform.util").root_file({ "gleam.toml" }),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("Format", function(opts)
|
|
||||||
conform.format({ formatters = opts.fargs })
|
|
||||||
end, {
|
|
||||||
nargs = "+",
|
|
||||||
complete = function()
|
|
||||||
local names = formatters_by_ft[vim.bo.filetype] or formatters_by_ft["_"] or {}
|
|
||||||
names = vim.list_extend(names, formatters_by_ft["*"] or {})
|
|
||||||
names = vim.tbl_flatten(names)
|
|
||||||
local formatters = vim.tbl_map(conform.get_formatter_info, names)
|
|
||||||
formatters = vim.tbl_filter(function(formatter)
|
|
||||||
return formatter.available
|
|
||||||
end, formatters)
|
|
||||||
return vim.tbl_map(function(formatter_info)
|
|
||||||
return formatter_info.name
|
|
||||||
end, formatters)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
require("gitsigns").setup()
|
|
||||||
require("which-key").add({
|
|
||||||
{ "<leader>gP", "<cmd>Gitsigns preview_hunk<cr>", desc = "Preview hunk (float)" },
|
|
||||||
{ "<leader>gR", "<cmd>Gitsigns reset_buffer<cr>", desc = "Reset buffer" },
|
|
||||||
{ "<leader>gS", "<cmd>Gitsigns stage_buffer<cr>", desc = "Stage buffer" },
|
|
||||||
{ "<leader>gp", "<cmd>Gitsigns preview_hunk_inline<cr>", desc = "Preview hunk (inline)" },
|
|
||||||
{ "<leader>gu", "<cmd>Gitsigns undo_stage_hunk<cr>", desc = "Undo stage hunk" },
|
|
||||||
{ "[h", "<cmd>Gitsigns prev_hunk<cr>", desc = "Previous hunk" },
|
|
||||||
{ "]h", "<cmd>Gitsigns next_hunk<cr>", desc = "Next hunk" },
|
|
||||||
{ "<leader>gr", "<cmd>Gitsigns reset_hunk<cr>", desc = "Reset hunk", mode = { "n", "v" } },
|
|
||||||
{ "<leader>gs", "<cmd>Gitsigns stage_hunk<cr>", desc = "Stage hunk", mode = { "n", "v" } },
|
|
||||||
{ "ih", ":<C-U>Gitsigns select_hunk<cr>", desc = "gitsigns hunk", mode = { "o", "x" } },
|
|
||||||
})
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
local ls = require("luasnip")
|
|
||||||
local types = require("luasnip.util.types")
|
|
||||||
|
|
||||||
-- Every unspecified option will be set to the default.
|
|
||||||
ls.setup({
|
|
||||||
history = true,
|
|
||||||
|
|
||||||
-- Update more often, :h events for more info.
|
|
||||||
update_events = "TextChanged,TextChangedI",
|
|
||||||
-- Snippets aren't automatically removed if their text is deleted.
|
|
||||||
-- `delete_check_events` determines on which events (:h events) a check for
|
|
||||||
-- deleted snippets is performed.
|
|
||||||
-- This can be especially useful when `history` is enabled.
|
|
||||||
delete_check_events = "TextChanged",
|
|
||||||
ext_opts = {
|
|
||||||
[types.choiceNode] = {
|
|
||||||
active = {
|
|
||||||
virt_text = { { "<--", "Error" } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ft_func = require("luasnip.extras.filetype_functions").from_pos_or_filetype,
|
|
||||||
})
|
|
||||||
|
|
||||||
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
require("mini.align").setup()
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
require("neodev").setup({
|
|
||||||
override = function(root_dir, library)
|
|
||||||
if root_dir:find("/home/moritz/.dotfiles/", 1, true) == 1 then
|
|
||||||
library.enabled = true
|
|
||||||
library.plugins = true
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
require("neotest").setup({
|
|
||||||
adapters = {
|
|
||||||
require("neotest-python")({
|
|
||||||
dap = { justMyCode = false },
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
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,
|
|
||||||
},
|
|
||||||
progress = {
|
|
||||||
enabled = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- 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
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
local null_ls = require("null-ls")
|
|
||||||
|
|
||||||
null_ls.setup({
|
|
||||||
sources = {
|
|
||||||
-- Code actions
|
|
||||||
require("none-ls-shellcheck.code_actions"),
|
|
||||||
null_ls.builtins.code_actions.statix,
|
|
||||||
-- Diagnostics
|
|
||||||
null_ls.builtins.diagnostics.checkmake,
|
|
||||||
null_ls.builtins.diagnostics.deadnix,
|
|
||||||
null_ls.builtins.diagnostics.dotenv_linter,
|
|
||||||
null_ls.builtins.diagnostics.fish,
|
|
||||||
require("none-ls-shellcheck.diagnostics"),
|
|
||||||
null_ls.builtins.diagnostics.statix,
|
|
||||||
null_ls.builtins.diagnostics.trail_space,
|
|
||||||
null_ls.builtins.diagnostics.yamllint,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
@ -1,229 +0,0 @@
|
||||||
local cmp = require("cmp")
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
require("luasnip.loaders.from_vscode").lazy_load()
|
|
||||||
|
|
||||||
cmp.setup({
|
|
||||||
formatting = {
|
|
||||||
format = require("lspkind").cmp_format({
|
|
||||||
mode = "symbol", -- show only symbol annotations
|
|
||||||
maxwidth = 50, -- prevent the popup from showing more than provided characters
|
|
||||||
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead
|
|
||||||
symbol_map = {
|
|
||||||
-- Copilot = "",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
snippet = {
|
|
||||||
-- REQUIRED - you must specify a snippet engine
|
|
||||||
expand = function(args)
|
|
||||||
require("luasnip").lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
|
||||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
|
||||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
|
||||||
["<S-CR>"] = cmp.mapping.abort(),
|
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
|
||||||
elseif luasnip.locally_jumpable(1) then
|
|
||||||
luasnip.jump(1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
|
|
||||||
elseif luasnip.locally_jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
["<C-n>"] = cmp.mapping(function(fallback)
|
|
||||||
if luasnip.choice_active() then
|
|
||||||
luasnip.change_choice(1)
|
|
||||||
elseif luasnip.locally_jumpable(1) then
|
|
||||||
luasnip.jump(1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
["<C-p>"] = cmp.mapping(function(fallback)
|
|
||||||
if luasnip.choice_active() then
|
|
||||||
luasnip.change_choice(-1)
|
|
||||||
elseif luasnip.locally_jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
}),
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ priority = 1, name = "async_path" },
|
|
||||||
{ priority = 1, name = "buffer" },
|
|
||||||
{ priority = 1, name = "spell" },
|
|
||||||
{ priority = 2, name = "nvim_lsp" },
|
|
||||||
-- { priority = 3, name = "copilot" },
|
|
||||||
{ priority = 3, name = "nvim_lsp_signature_help" },
|
|
||||||
{ priority = 4, name = "luasnip" },
|
|
||||||
{ priority = 4, name = "vimtex" },
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Set configuration for specific filetype.
|
|
||||||
cmp.setup.filetype("gitcommit", {
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = "buffer" },
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
|
||||||
cmp.setup.cmdline({ "/", "?" }, {
|
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
|
||||||
sources = {
|
|
||||||
{ name = "buffer" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
|
||||||
cmp.setup.cmdline(":", {
|
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = "async_path" },
|
|
||||||
}, {
|
|
||||||
{ name = "cmdline" },
|
|
||||||
}),
|
|
||||||
enabled = function()
|
|
||||||
-- Set of commands where cmp will be disabled
|
|
||||||
local disabled = {
|
|
||||||
IncRename = true,
|
|
||||||
}
|
|
||||||
-- Get first word of cmdline
|
|
||||||
local cmd = vim.fn.getcmdline():match("%S+")
|
|
||||||
-- Return true if cmd isn't disabled
|
|
||||||
-- else call/return cmp.close(), which returns false
|
|
||||||
return not disabled[cmd] or cmp.close()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
-- If you want insert `(` after select function or method item
|
|
||||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
|
||||||
local handlers = require("nvim-autopairs.completion.handlers")
|
|
||||||
|
|
||||||
cmp.event:on(
|
|
||||||
"confirm_done",
|
|
||||||
cmp_autopairs.on_confirm_done({
|
|
||||||
filetypes = {
|
|
||||||
-- "*" is a alias to all filetypes
|
|
||||||
["*"] = {
|
|
||||||
["("] = {
|
|
||||||
kind = {
|
|
||||||
cmp.lsp.CompletionItemKind.Function,
|
|
||||||
cmp.lsp.CompletionItemKind.Method,
|
|
||||||
},
|
|
||||||
handler = handlers["*"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- Disable for functional languages
|
|
||||||
haskell = false,
|
|
||||||
nix = false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
local pickers = require("telescope.pickers")
|
|
||||||
local finders = require("telescope.finders")
|
|
||||||
local conf = require("telescope.config").values
|
|
||||||
local actions = require("telescope.actions")
|
|
||||||
local action_state = require("telescope.actions.state")
|
|
||||||
|
|
||||||
local all_sources = vim.deepcopy(cmp.get_config().sources)
|
|
||||||
|
|
||||||
local find = function(sources, name)
|
|
||||||
for k, source in ipairs(sources) do
|
|
||||||
if source.name == name then
|
|
||||||
return k
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local is_active = function(name)
|
|
||||||
local active_sources = cmp.get_config().sources
|
|
||||||
local index = find(active_sources, name)
|
|
||||||
return index ~= nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local enable_source = function(name, force)
|
|
||||||
if force or not is_active(name) then
|
|
||||||
local source_index = find(all_sources, name)
|
|
||||||
if source_index ~= nil then
|
|
||||||
local active_sources = cmp.get_config().sources
|
|
||||||
local source = all_sources[source_index]
|
|
||||||
table.insert(active_sources, 1, source)
|
|
||||||
cmp.setup({ sources = active_sources })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local disable_source = function(identifier)
|
|
||||||
if type(identifier) == "string" then
|
|
||||||
identifier = find(all_sources, identifier)
|
|
||||||
end
|
|
||||||
local active_sources = cmp.get_config().sources
|
|
||||||
table.remove(active_sources, identifier)
|
|
||||||
end
|
|
||||||
|
|
||||||
local toggle_sources = function(name)
|
|
||||||
local active_sources = cmp.get_config().sources
|
|
||||||
local index = find(active_sources, name)
|
|
||||||
if index ~= nil then
|
|
||||||
disable_source(index)
|
|
||||||
else
|
|
||||||
enable_source(name, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- our picker function: sources
|
|
||||||
local sources_picker = function(opts)
|
|
||||||
opts = opts or {}
|
|
||||||
pickers
|
|
||||||
.new(opts, {
|
|
||||||
prompt_title = "sources",
|
|
||||||
finder = finders.new_table({
|
|
||||||
results = vim.tbl_map(function(source)
|
|
||||||
return source.name
|
|
||||||
end, all_sources),
|
|
||||||
entry_maker = function(entry)
|
|
||||||
return {
|
|
||||||
value = entry,
|
|
||||||
display = function(tbl)
|
|
||||||
local name = tbl["ordinal"]
|
|
||||||
local active = is_active(name)
|
|
||||||
return string.format("%s %s", name, active and "✅" or "❌")
|
|
||||||
end,
|
|
||||||
ordinal = entry,
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}),
|
|
||||||
sorter = conf.generic_sorter(opts),
|
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
|
||||||
actions.select_default:replace(function()
|
|
||||||
actions.close(prompt_bufnr)
|
|
||||||
local selection = action_state.get_selected_entry()
|
|
||||||
toggle_sources(selection["value"])
|
|
||||||
end)
|
|
||||||
return true
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
:find()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- autocommand for sources_picker
|
|
||||||
vim.api.nvim_create_user_command("CmpToggle", sources_picker, {})
|
|
||||||
|
|
||||||
-- disable sources by default
|
|
||||||
-- disable_source("codeium")
|
|
||||||
|
|
@ -1,225 +0,0 @@
|
||||||
local lsp_lines = require("lsp_lines")
|
|
||||||
lsp_lines.setup()
|
|
||||||
-- Disable virtual_text since it's redundant due to lsp_lines.
|
|
||||||
vim.diagnostic.config({
|
|
||||||
virtual_text = false,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
|
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
||||||
|
|
||||||
-- Tell the server the capability of foldingRange,
|
|
||||||
-- Neovim hasn't added foldingRange to default capabilities, users must add it manually
|
|
||||||
capabilities.textDocument.foldingRange = {
|
|
||||||
dynamicRegistration = false,
|
|
||||||
lineFoldingOnly = true,
|
|
||||||
}
|
|
||||||
-- NOTE https://github.com/neovim/neovim/pull/22405
|
|
||||||
capabilities.didChangeWatchedFiles = {
|
|
||||||
dynamicRegistration = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
|
||||||
local on_attach_def = function(client, bufnr)
|
|
||||||
require("which-key").add({
|
|
||||||
{ "<leader>c", buffer = bufnr, group = "code" },
|
|
||||||
{
|
|
||||||
"<leader>cr",
|
|
||||||
function()
|
|
||||||
return ":IncRename " .. vim.fn.expand("<cword>")
|
|
||||||
end,
|
|
||||||
buffer = bufnr,
|
|
||||||
desc = "Rename",
|
|
||||||
expr = true,
|
|
||||||
replace_keycodes = false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>ti",
|
|
||||||
function()
|
|
||||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
|
||||||
end,
|
|
||||||
buffer = bufnr,
|
|
||||||
desc = "LSP inlay hints",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>tl",
|
|
||||||
function()
|
|
||||||
lsp_lines.toggle()
|
|
||||||
if vim.diagnostic.is_disabled() then
|
|
||||||
vim.diagnostic.enable()
|
|
||||||
else
|
|
||||||
vim.diagnostic.disable()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
buffer = bufnr,
|
|
||||||
desc = "LSP lines",
|
|
||||||
},
|
|
||||||
{ "K", vim.lsp.buf.hover, buffer = bufnr, desc = "Hover" },
|
|
||||||
{ "[d", vim.diagnostic.goto_prev, buffer = bufnr, desc = "Previous diagnostic" },
|
|
||||||
{ "]d", vim.diagnostic.goto_next, buffer = bufnr, desc = "Next diagnostic" },
|
|
||||||
{ "gD", vim.lsp.buf.declaration, buffer = bufnr, desc = "Goto declaration" },
|
|
||||||
{ "gI", "<cmd>Telescope lsp_implementations<cr>", buffer = bufnr, desc = "Goto implementation" },
|
|
||||||
{ "gK", vim.lsp.buf.signature_help, buffer = bufnr, desc = "Signature help" },
|
|
||||||
{
|
|
||||||
"gd",
|
|
||||||
function()
|
|
||||||
require("telescope.builtin").lsp_definitions({ reuse_win = true })
|
|
||||||
end,
|
|
||||||
buffer = bufnr,
|
|
||||||
desc = "Goto definition",
|
|
||||||
},
|
|
||||||
{ "gr", "<cmd>Telescope lsp_references<cr>", buffer = bufnr, desc = "Goto references" },
|
|
||||||
{
|
|
||||||
"gt",
|
|
||||||
|
|
||||||
function()
|
|
||||||
require("telescope.builtin").lsp_type_definitions({ reuse_win = true })
|
|
||||||
end,
|
|
||||||
buffer = bufnr,
|
|
||||||
desc = "Goto type definition",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>cc",
|
|
||||||
require("actions-preview").code_actions,
|
|
||||||
buffer = bufnr,
|
|
||||||
desc = "Code action",
|
|
||||||
mode = { "n", "v" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>cf",
|
|
||||||
function()
|
|
||||||
vim.lsp.buf.format({ async = true })
|
|
||||||
end,
|
|
||||||
buffer = bufnr,
|
|
||||||
desc = "Format (lsp)",
|
|
||||||
mode = { "n", "v" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if client.server_capabilities.inlayHintProvider then
|
|
||||||
local slow_lsp_servers = {
|
|
||||||
"rust_analyzer",
|
|
||||||
}
|
|
||||||
local timeout = vim.tbl_contains(slow_lsp_servers, client.name, {}) and 500 or 0
|
|
||||||
vim.defer_fn(function()
|
|
||||||
vim.lsp.inlay_hint.enable(true, { bufnr })
|
|
||||||
end, timeout)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local lspconfig_default_options = {
|
|
||||||
on_attach = on_attach_def,
|
|
||||||
capabilities = capabilities,
|
|
||||||
flags = {
|
|
||||||
debounce_text_changes = 100,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
---function to add default options to lspconfig
|
|
||||||
---@param lsp string
|
|
||||||
---@param options table
|
|
||||||
---@return nil
|
|
||||||
local function lspconfig_setup(lsp, options)
|
|
||||||
local final_options = vim.tbl_deep_extend("force", lspconfig_default_options, options)
|
|
||||||
lspconfig[lsp].setup(final_options)
|
|
||||||
end
|
|
||||||
|
|
||||||
local servers = {
|
|
||||||
"bashls",
|
|
||||||
"gleam",
|
|
||||||
"gopls",
|
|
||||||
"pylsp",
|
|
||||||
"ruff",
|
|
||||||
"templ",
|
|
||||||
"typst_lsp",
|
|
||||||
}
|
|
||||||
for _, lsp in ipairs(servers) do
|
|
||||||
lspconfig_setup(lsp, {})
|
|
||||||
end
|
|
||||||
|
|
||||||
lspconfig_setup("elixirls", {
|
|
||||||
cmd = { "elixir-ls" },
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig_setup("nil_ls", {
|
|
||||||
settings = {
|
|
||||||
flake = {
|
|
||||||
autoArchive = true,
|
|
||||||
autoEvalInputs = true,
|
|
||||||
nixpkgsInputName = "nixpkgs",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig_setup("nixd", {
|
|
||||||
settings = {
|
|
||||||
nixd = {
|
|
||||||
nixpkgs = {
|
|
||||||
expr = "import <nixpkgs> { }",
|
|
||||||
},
|
|
||||||
options = {
|
|
||||||
nixos = {
|
|
||||||
expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.nixos-desktop.options',
|
|
||||||
},
|
|
||||||
["flake-parts"] = {
|
|
||||||
expr = '(builtins.getFlake ("git+file://" + toString ./.)).debug.options',
|
|
||||||
},
|
|
||||||
["flake-parts2"] = {
|
|
||||||
expr = '(builtins.getFlake ("git+file://" + toString ./.)).currentSystem.options',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Add templ filetype
|
|
||||||
vim.filetype.add({ extension = { templ = "templ" } })
|
|
||||||
|
|
||||||
lspconfig_setup("htmx", {
|
|
||||||
filetypes = { "html", "templ" },
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig_setup("tailwindcss", {
|
|
||||||
filetypes = { "templ", "astro", "javascript", "typescript", "react" },
|
|
||||||
init_options = { userLanguages = { templ = "html" } },
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig_setup("rust_analyzer", {
|
|
||||||
settings = {
|
|
||||||
["rust-analyzer"] = {
|
|
||||||
checkOnSave = {
|
|
||||||
command = "clippy",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig_setup("lua_ls", {
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
runtime = {
|
|
||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
||||||
version = "LuaJIT",
|
|
||||||
path = vim.split(package.path, ";"),
|
|
||||||
},
|
|
||||||
diagnostics = {
|
|
||||||
-- Get the language server to recognize the `vim` global
|
|
||||||
globals = { "vim" },
|
|
||||||
},
|
|
||||||
workspace = {
|
|
||||||
-- Make the server aware of Neovim runtime files
|
|
||||||
library = vim.api.nvim_get_runtime_file("", true),
|
|
||||||
checkThirdParty = false,
|
|
||||||
},
|
|
||||||
-- Do not send telemetry data containing a randomized but unique identifier
|
|
||||||
telemetry = {
|
|
||||||
enable = false,
|
|
||||||
},
|
|
||||||
format = {
|
|
||||||
enable = false,
|
|
||||||
},
|
|
||||||
hint = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
require("nvim-treesitter.configs").setup({
|
|
||||||
textsubjects = {
|
|
||||||
enable = true,
|
|
||||||
prev_selection = ",", -- (Optional) keymap to select the previous selection
|
|
||||||
keymaps = { ["."] = "textsubjects-smart" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
require("nvim-treesitter.configs").setup()
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
vim.o.foldcolumn = "1" -- '0' is not bad
|
|
||||||
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
|
|
||||||
vim.o.foldlevelstart = 99
|
|
||||||
vim.o.foldenable = true
|
|
||||||
|
|
||||||
local ftMap = {
|
|
||||||
vim = "indent",
|
|
||||||
python = { "indent" },
|
|
||||||
git = "",
|
|
||||||
}
|
|
||||||
|
|
||||||
---@param bufnr number
|
|
||||||
---@return Promise
|
|
||||||
local function customizeSelector(bufnr)
|
|
||||||
local function handleFallbackException(err, providerName)
|
|
||||||
if type(err) == "string" and err:match("UfoFallbackException") then
|
|
||||||
return require("ufo").getFolds(bufnr, providerName)
|
|
||||||
else
|
|
||||||
return require("promise").reject(err)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return require("ufo")
|
|
||||||
.getFolds(bufnr, "lsp")
|
|
||||||
:catch(function(err)
|
|
||||||
return handleFallbackException(err, "treesitter")
|
|
||||||
end)
|
|
||||||
:catch(function(err)
|
|
||||||
return handleFallbackException(err, "indent")
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local handler = function(virtText, lnum, endLnum, width, truncate)
|
|
||||||
local newVirtText = {}
|
|
||||||
local suffix = (" %d "):format(endLnum - lnum)
|
|
||||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
|
||||||
local targetWidth = width - sufWidth
|
|
||||||
local curWidth = 0
|
|
||||||
for _, chunk in ipairs(virtText) do
|
|
||||||
local chunkText = chunk[1]
|
|
||||||
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
|
||||||
if targetWidth > curWidth + chunkWidth then
|
|
||||||
table.insert(newVirtText, chunk)
|
|
||||||
else
|
|
||||||
chunkText = truncate(chunkText, targetWidth - curWidth)
|
|
||||||
local hlGroup = chunk[2]
|
|
||||||
table.insert(newVirtText, { chunkText, hlGroup })
|
|
||||||
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
|
||||||
-- str width returned from truncate() may less than 2nd argument, need padding
|
|
||||||
if curWidth + chunkWidth < targetWidth then
|
|
||||||
suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
|
|
||||||
end
|
|
||||||
break
|
|
||||||
end
|
|
||||||
curWidth = curWidth + chunkWidth
|
|
||||||
end
|
|
||||||
table.insert(newVirtText, { suffix, "MoreMsg" })
|
|
||||||
return newVirtText
|
|
||||||
end
|
|
||||||
|
|
||||||
require("ufo").setup({
|
|
||||||
provider_selector = function(_, filetype, _)
|
|
||||||
return ftMap[filetype] or customizeSelector
|
|
||||||
end,
|
|
||||||
fold_virt_text_handler = handler,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself
|
|
||||||
require("which-key").register({
|
|
||||||
z = {
|
|
||||||
R = { require("ufo").openAllFolds, "Open all folds" },
|
|
||||||
M = { require("ufo").closeAllFolds, "Close all folds" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
require("telescope").load_extension("fzf")
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
vim.g.startuptime_tries = 10
|
|
||||||
vim.g.startuptime_exe_path = "vim"
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
vim.o.timeout = true
|
|
||||||
vim.o.timeoutlen = 500
|
|
||||||
|
|
||||||
-- Delete
|
|
||||||
require("which-key").add({
|
|
||||||
{ "<leader>d", group = "delete" },
|
|
||||||
{ "<leader>db", "<cmd>bd<cr>", desc = "Delete buffer" },
|
|
||||||
{ "<leader>dw", "<C-w>c", desc = "Delete window" },
|
|
||||||
})
|
|
||||||
|
|
||||||
-- buffer
|
|
||||||
require("which-key").add({
|
|
||||||
{ "[b", "<cmd>bprevious<cr>", desc = "Previous buffer" },
|
|
||||||
{ "]b", "<cmd>bnext<cr>", desc = "Next buffer" },
|
|
||||||
})
|
|
||||||
|
|
||||||
-- window
|
|
||||||
require("which-key").add({
|
|
||||||
{ "<leader>w", group = "window" },
|
|
||||||
{ "<leader>w-", "<C-w>s", desc = "Split window vertically" },
|
|
||||||
{ "<leader>ww", "<C-w>w", desc = "Switch window" },
|
|
||||||
{ "<leader>w|", "<C-w>v", desc = "Split window horizontally" },
|
|
||||||
})
|
|
||||||
|
|
||||||
-- better descriptions for navigation
|
|
||||||
require("which-key").add({
|
|
||||||
{ "<leader>c", group = "code" },
|
|
||||||
{ "<leader>f", group = "file/find" },
|
|
||||||
{ "<leader>g", group = "git" },
|
|
||||||
{ "<leader>s", group = "search" },
|
|
||||||
{ "<leader>t", group = "toggle" },
|
|
||||||
{ "[", group = "prev" },
|
|
||||||
{ "]", group = "next" },
|
|
||||||
{ "g", group = "goto" },
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Clear search with <esc>
|
|
||||||
require("which-key").add({
|
|
||||||
{ "<esc>", "<cmd>noh<cr><esc>", desc = "Escape and clear hlsearch", mode = { "i", "n" } },
|
|
||||||
})
|
|
||||||
|
|
||||||
-- better indenting
|
|
||||||
require("which-key").add({
|
|
||||||
{ "<", "<gv", desc = "Shift left", mode = "v" },
|
|
||||||
{ ">", ">gv", desc = "Shift right", mode = "v" },
|
|
||||||
})
|
|
||||||
|
|
||||||
-- better yank in visual mode
|
|
||||||
require("which-key").add({
|
|
||||||
{ "y", "ygv<esc>", desc = "Yank", mode = "v" },
|
|
||||||
})
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
local telekasten = require("telekasten")
|
|
||||||
telekasten.setup({
|
|
||||||
home = vim.fn.expand("~/Documents/Nextcloud/Notes/zettelkasten"),
|
|
||||||
auto_set_filetype = false,
|
|
||||||
image_subdir = "assets",
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
|
|
||||||
pattern = "*/zettelkasten/*",
|
|
||||||
callback = function(_)
|
|
||||||
require("which-key").register({
|
|
||||||
g = {
|
|
||||||
f = { telekasten.follow_link, "Follow link" },
|
|
||||||
r = { telekasten.show_backlinks, "Show backlinks" },
|
|
||||||
},
|
|
||||||
["<leader>"] = {
|
|
||||||
f = {
|
|
||||||
f = { telekasten.find_notes, "Find note" },
|
|
||||||
n = { telekasten.new_note, "New note" },
|
|
||||||
},
|
|
||||||
s = {
|
|
||||||
g = { telekasten.search_note, "Grep notes" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}, { buffer = vim.fn.bufnr("%") })
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
11
modules/programs/nvim/plugins/lualine.nix
Normal file
11
modules/programs/nvim/plugins/lualine.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{ config, lib, pkgs, inputs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption mkIf readFile;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
home-manager.users.moritz.programs.nixvim.plugins.lualine = {
|
||||||
|
enable = true;
|
||||||
|
lazyLoad.settings.event = [ "DeferredUIEnter" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,14 @@ in
|
||||||
};
|
};
|
||||||
programs.nixvim = {
|
programs.nixvim = {
|
||||||
plugins.luasnip = {
|
plugins.luasnip = {
|
||||||
|
lazyLoad.settings.event = [ "InsertEnter" ];
|
||||||
|
lazyLoad.settings.after = /* lua */ ''
|
||||||
|
function()
|
||||||
|
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
|
||||||
|
require("luasnip.loaders.from_snipmate").lazy_load({ paths = "~/.config/nvim/snippets" })
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
end
|
||||||
|
'';
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
history = true;
|
history = true;
|
||||||
|
|
@ -28,11 +36,6 @@ in
|
||||||
ft_func.__raw = ''require("luasnip.extras.filetype_functions").from_pos_or_filetype'';
|
ft_func.__raw = ''require("luasnip.extras.filetype_functions").from_pos_or_filetype'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
extraConfigLuaPost = ''
|
|
||||||
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
|
|
||||||
require("luasnip.loaders.from_snipmate").lazy_load({ paths = "~/.config/nvim/snippets" })
|
|
||||||
require("luasnip.loaders.from_vscode").lazy_load()
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,5 @@ let
|
||||||
inherit (lib) mkEnableOption mkIf readFile;
|
inherit (lib) mkEnableOption mkIf readFile;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
home-manager.users.moritz.programs.nixvim = {
|
home-manager.users.moritz.programs.nixvim.plugins.lz-n.enable = true;
|
||||||
plugins.lualine.enable = true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,5 @@ let
|
||||||
inherit (lib) mkEnableOption mkIf readFile;
|
inherit (lib) mkEnableOption mkIf readFile;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
home-manager.users.moritz.programs.nixvim = {
|
home-manager.users.moritz.programs.nixvim.plugins.nvim-ufo.enable = true;
|
||||||
plugins.nvim-ufo.enable = true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
7
modules/programs/nvim/plugins/otter.nix
Normal file
7
modules/programs/nvim/plugins/otter.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
_:
|
||||||
|
|
||||||
|
{
|
||||||
|
home-manager.users.moritz.programs.nixvim.plugins.otter = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
12
modules/programs/nvim/plugins/render-markdown.nix
Normal file
12
modules/programs/nvim/plugins/render-markdown.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{ config, lib, pkgs, inputs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption mkIf readFile;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
home-manager.users.moritz.programs.nixvim.plugins.render-markdown = {
|
||||||
|
enable = true;
|
||||||
|
settings.latex.enable = false;
|
||||||
|
lazyLoad.settings.event = "BufRead *.md";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,68 +1,26 @@
|
||||||
{ pkgs, inputs, lib, ... }:
|
{ config, lib, pkgs, inputs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption mkIf readFile;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
config.home-manager.users.moritz.programs.neovim.lazy.plugins = [
|
home-manager.users.moritz.programs.nixvim = {
|
||||||
(
|
plugins.treesitter = {
|
||||||
let
|
enable = true;
|
||||||
nvim-treesitter = pkgs.vimPlugins.nvim-treesitter;
|
folding = true;
|
||||||
parserDir = pkgs.symlinkJoin {
|
nixvimInjections = true;
|
||||||
name = "tresitter-grammars-all";
|
settings.indent.enable = true;
|
||||||
paths = nvim-treesitter.withAllGrammars.dependencies;
|
settings.highlight.enable = true;
|
||||||
};
|
settings.incremental_selection = {
|
||||||
in
|
enable = true;
|
||||||
{
|
keymaps.init_selection = "gn";
|
||||||
plugin = nvim-treesitter;
|
keymaps.node_decremental = "gp";
|
||||||
event = [ "BufReadPost" "BufNewFile" ];
|
keymaps.node_incremental = "gn";
|
||||||
opts = {
|
};
|
||||||
sync_install = false;
|
lazyLoad.settings.event = [ "DeferredUIEnter" ];
|
||||||
auto_install = false;
|
};
|
||||||
highlight = {
|
performance.combinePlugins.standalonePlugins = [
|
||||||
enable = true;
|
"nvim-treesitter"
|
||||||
disable = [ "latex" ];
|
];
|
||||||
};
|
};
|
||||||
textobjects =
|
|
||||||
{
|
|
||||||
select =
|
|
||||||
{
|
|
||||||
enable = true;
|
|
||||||
|
|
||||||
# Automatically jump forward to textobj, similar to targets.vim
|
|
||||||
lookahead = false;
|
|
||||||
|
|
||||||
keymaps = {
|
|
||||||
# You can use the capture groups defined in textobjects.scm
|
|
||||||
"af" = {
|
|
||||||
query = "@function.outer";
|
|
||||||
desc = "Select outer part of a function region";
|
|
||||||
};
|
|
||||||
"if" = {
|
|
||||||
query = "@function.inner";
|
|
||||||
desc = "Select inner part of a function region";
|
|
||||||
};
|
|
||||||
"ac" = {
|
|
||||||
query = "@class.outer";
|
|
||||||
desc = "Select outer part of a class region";
|
|
||||||
};
|
|
||||||
"ic" = {
|
|
||||||
query = "@class.inner";
|
|
||||||
desc = "Select inner part of a class region";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
conf =
|
|
||||||
/* lua */ ''
|
|
||||||
vim.opt.runtimepath:append("${parserDir}")
|
|
||||||
local final_opts = vim.tbl_deep_extend("keep", opts, { parser_install_dir = "${parserDir}" })
|
|
||||||
require('nvim-treesitter.configs').setup(final_opts)
|
|
||||||
'';
|
|
||||||
priority = 100;
|
|
||||||
dependencies = [
|
|
||||||
{ plugin = pkgs.vimPlugins.nvim-treesitter-textobjects; }
|
|
||||||
{ plugin = pkgs.vimPlugins.nvim-ts-context-commentstring; opts = { }; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
{ pkgs, lib, inputs, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (lib) readFile;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
config.home-manager.users.moritz.programs.neovim.lazy.plugins = [
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.which-key-nvim;
|
|
||||||
lazy = false;
|
|
||||||
conf = readFile ./lua/which-key-nvim.lua;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.catppuccin-nvim;
|
|
||||||
conf = readFile ./lua/catppuccin-nvim.lua;
|
|
||||||
lazy = false;
|
|
||||||
priority = 99;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.todo-comments-nvim;
|
|
||||||
dependencies = [{ plugin = pkgs.vimPlugins.plenary-nvim; }];
|
|
||||||
opts = { };
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.dressing-nvim;
|
|
||||||
event = [ "VeryLazy" ];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.gitsigns-nvim;
|
|
||||||
event = [ "BufReadPost" "BufNewFile" ];
|
|
||||||
conf = readFile ./lua/gitsigns-nvim.lua;
|
|
||||||
dependencies = [{ plugin = pkgs.vimPlugins.which-key-nvim; }];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimUtils.buildVimPlugin {
|
|
||||||
pname = "hawtkeys-nvim";
|
|
||||||
version = lib.my.mkVersionInput inputs.hawtkeys-nvim;
|
|
||||||
src = inputs.hawtkeys-nvim;
|
|
||||||
};
|
|
||||||
cmd = [ "Hawtkeys" "HawtkeysAll" "HawtkeysDupes" ];
|
|
||||||
opts = { };
|
|
||||||
dependencies = [
|
|
||||||
{ plugin = pkgs.vimPlugins.plenary-nvim; }
|
|
||||||
{ plugin = pkgs.vimPlugins.nvim-treesitter; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.zen-mode-nvim;
|
|
||||||
keys = [
|
|
||||||
{ key = "<leader>tz"; cmd = "<cmd>ZenMode<cr>"; desc = "Zen mode"; }
|
|
||||||
];
|
|
||||||
conf = /* lua */ ''
|
|
||||||
require("zen-mode").setup({
|
|
||||||
plugins = {
|
|
||||||
tmux = {
|
|
||||||
enabled = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
'';
|
|
||||||
dependencies = [
|
|
||||||
{
|
|
||||||
plugin = pkgs.vimPlugins.twilight-nvim;
|
|
||||||
keys = [
|
|
||||||
{ key = "<leader>tZ"; cmd = "<cmd>Twilight<cr>"; desc = "Twilight mode"; }
|
|
||||||
];
|
|
||||||
conf = /* lua */ ''
|
|
||||||
require("twilight").setup({
|
|
||||||
context = 20,
|
|
||||||
expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
|
|
||||||
"function",
|
|
||||||
"function_definition",
|
|
||||||
"if_statement",
|
|
||||||
"method",
|
|
||||||
"method_definition",
|
|
||||||
"table",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -7,7 +7,8 @@ in
|
||||||
home-manager.users.moritz.programs.nixvim = {
|
home-manager.users.moritz.programs.nixvim = {
|
||||||
plugins.vimtex = {
|
plugins.vimtex = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings.view_method = "zathura";
|
texlivePackage = pkgs.texliveFull;
|
||||||
|
settings.view_method = "zathura_simple";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue