refactor(nvim)!: add opts option
This commit is contained in:
parent
12a5420ee9
commit
6a125a1df6
27 changed files with 273 additions and 238 deletions
19
modules/programs/nvim/plugins/lua/catppuccin-nvim.lua
Normal file
19
modules/programs/nvim/plugins/lua/catppuccin-nvim.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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")
|
||||
70
modules/programs/nvim/plugins/lua/formatter-nvim.lua
Normal file
70
modules/programs/nvim/plugins/lua/formatter-nvim.lua
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
|
||||
require("formatter").setup({
|
||||
-- Enable or disable logging
|
||||
logging = true,
|
||||
-- Set the log level
|
||||
log_level = vim.log.levels.WARN,
|
||||
-- All formatter configurations are opt-in
|
||||
filetype = {
|
||||
go = {
|
||||
require("formatter.filetypes.go").gofmt,
|
||||
},
|
||||
json = {
|
||||
require("formatter.filetypes.json").jq,
|
||||
},
|
||||
lua = {
|
||||
require("formatter.filetypes.lua").stylua,
|
||||
},
|
||||
nix = {
|
||||
require("formatter.filetypes.nix").nixpkgs_fmt,
|
||||
},
|
||||
python = {
|
||||
require("formatter.filetypes.python").black,
|
||||
},
|
||||
rust = {
|
||||
require("formatter.filetypes.rust").rustfmt,
|
||||
},
|
||||
sh = {
|
||||
require("formatter.filetypes.sh").shfmt,
|
||||
},
|
||||
toml = {
|
||||
require("formatter.filetypes.toml").taplo,
|
||||
},
|
||||
yaml = {
|
||||
require("formatter.filetypes.yaml").yamlfmt,
|
||||
},
|
||||
|
||||
-- HACK to use specific formatters only when specified
|
||||
alejandra = {
|
||||
require("formatter.filetypes.nix").alejandra,
|
||||
},
|
||||
isort = {
|
||||
require("formatter.filetypes.python").isort,
|
||||
},
|
||||
|
||||
-- Use the special "*" filetype for defining formatter configurations on
|
||||
-- any filetype
|
||||
["*"] = {
|
||||
-- "formatter.filetypes.any" defines default configurations for any
|
||||
-- filetype
|
||||
require("formatter.filetypes.any").remove_trailing_whitespace,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("Fmt", function(opts)
|
||||
local params = vim.split(opts.args, "%s+", { trimempty = true })
|
||||
local filetype = vim.bo.filetype
|
||||
vim.cmd("set filetype=" .. params[1]) -- fake filetype
|
||||
vim.cmd(":Format")
|
||||
vim.cmd("set filetype=" .. filetype) -- restore original filetype
|
||||
end, {
|
||||
nargs = 1,
|
||||
complete = function()
|
||||
local languages = {
|
||||
nix = { "alejandra" },
|
||||
python = { "isort" },
|
||||
}
|
||||
return languages[vim.bo.filetype] or {}
|
||||
end,
|
||||
})
|
||||
15
modules/programs/nvim/plugins/lua/gitsigns-nvim.lua
Normal file
15
modules/programs/nvim/plugins/lua/gitsigns-nvim.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
require("gitsigns").setup()
|
||||
require("which-key").register({
|
||||
["[h"] = { "<cmd>Gitsigns prev_hunk<cr>", "Previous hunk" },
|
||||
["]h"] = { "<cmd>Gitsigns next_hunk<cr>", "Next hunk" },
|
||||
["<leader>g"] = {
|
||||
s = { "<cmd>Gitsigns stage_hunk<cr>", "Stage hunk", mode = { "n", "v" } },
|
||||
r = { "<cmd>Gitsigns reset_hunk<cr>", "Reset hunk", mode = { "n", "v" } },
|
||||
S = { "<cmd>Gitsigns stage_buffer<cr>", "Stage buffer" },
|
||||
R = { "<cmd>Gitsigns reset_buffer<cr>", "Reset buffer" },
|
||||
u = { "<cmd>Gitsigns undo_stage_hunk<cr>", "Undo stage hunk" },
|
||||
p = { "<cmd>Gitsigns preview_hunk_inline<cr>", "Preview hunk (inline)" },
|
||||
P = { "<cmd>Gitsigns preview_hunk<cr>", "Preview hunk (float)" },
|
||||
},
|
||||
["ih"] = { ":<C-U>Gitsigns select_hunk<cr>", "gitsigns hunk", mode = { "o", "x" } },
|
||||
})
|
||||
60
modules/programs/nvim/plugins/lua/mini-nvim.lua
Normal file
60
modules/programs/nvim/plugins/lua/mini-nvim.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
require("mini.align").setup()
|
||||
require("mini.move").setup()
|
||||
require("mini.starter").setup()
|
||||
|
||||
require("mini.statusline").setup({
|
||||
content = {
|
||||
active = function()
|
||||
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
|
||||
local git = MiniStatusline.section_git({ trunc_width = 75 })
|
||||
local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })
|
||||
local filename = MiniStatusline.section_filename({ trunc_width = 140 })
|
||||
local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
|
||||
local location = MiniStatusline.section_location({ trunc_width = 75 })
|
||||
local mode_hl_inverse = mode_hl .. "Inverse"
|
||||
-- Usage of `MiniStatusline.combine_groups()` ensures highlighting and
|
||||
-- correct padding with spaces between groups (accounts for 'missing'
|
||||
-- sections, etc.)
|
||||
return MiniStatusline.combine_groups({
|
||||
{ hl = mode_hl_inverse, strings = {} },
|
||||
"",
|
||||
{ hl = mode_hl, strings = { mode } },
|
||||
{ hl = "MiniStatuslineDevinfo", strings = { git, diagnostics } },
|
||||
"%<", -- Mark general truncate point
|
||||
{ hl = "MiniStatuslineFilename", strings = { filename } },
|
||||
"%=", -- End left alignment
|
||||
{ hl = "MiniStatuslineFileinfo", strings = { fileinfo } },
|
||||
{ hl = mode_hl, strings = { location } },
|
||||
{ hl = mode_hl_inverse, strings = {} },
|
||||
"",
|
||||
})
|
||||
end,
|
||||
},
|
||||
})
|
||||
local MiniStatuslineModes = {
|
||||
"MiniStatuslineModeInsert",
|
||||
"MiniStatuslineModeNormal",
|
||||
"MiniStatuslineModeReplace",
|
||||
"MiniStatuslineModeVisual",
|
||||
"MiniStatuslineModeCommand",
|
||||
"MiniStatuslineModeOther",
|
||||
}
|
||||
for _, mode_hl in ipairs(MiniStatuslineModes) do
|
||||
local hl_table = vim.api.nvim_get_hl(0, { name = mode_hl })
|
||||
local fg = hl_table.fg
|
||||
hl_table.fg = hl_table.bg
|
||||
hl_table.bg = fg
|
||||
vim.api.nvim_set_hl(0, mode_hl .. "Inverse", hl_table)
|
||||
end
|
||||
|
||||
local animate = require("mini.animate")
|
||||
local animation = {
|
||||
timing = animate.gen_timing.quadratic({ duration = 100, unit = "total" }),
|
||||
}
|
||||
animate.setup({
|
||||
cursor = animation,
|
||||
scroll = { enable = false },
|
||||
resize = animation,
|
||||
open = animation,
|
||||
close = animation,
|
||||
})
|
||||
8
modules/programs/nvim/plugins/lua/neodev-nvim.lua
Normal file
8
modules/programs/nvim/plugins/lua/neodev-nvim.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
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,
|
||||
})
|
||||
21
modules/programs/nvim/plugins/lua/noice-nvim.lua
Normal file
21
modules/programs/nvim/plugins/lua/noice-nvim.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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
|
||||
},
|
||||
})
|
||||
31
modules/programs/nvim/plugins/lua/null-ls-nvim.lua
Normal file
31
modules/programs/nvim/plugins/lua/null-ls-nvim.lua
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
local null_ls = require("null-ls")
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
-- Code actions
|
||||
null_ls.builtins.code_actions.shellcheck,
|
||||
null_ls.builtins.code_actions.statix,
|
||||
-- Completion
|
||||
null_ls.builtins.completion.spell,
|
||||
-- Diagnostics
|
||||
null_ls.builtins.diagnostics.deadnix,
|
||||
null_ls.builtins.diagnostics.shellcheck,
|
||||
null_ls.builtins.diagnostics.statix,
|
||||
},
|
||||
})
|
||||
|
||||
-- disable (c)spell initially
|
||||
null_ls.disable("spell")
|
||||
|
||||
-- make sources toggle able
|
||||
require("which-key").register({
|
||||
n = {
|
||||
name = "null-ls",
|
||||
s = {
|
||||
function()
|
||||
null_ls.toggle("spell")
|
||||
end,
|
||||
"spell",
|
||||
},
|
||||
},
|
||||
}, { prefix = "<leader>t" })
|
||||
114
modules/programs/nvim/plugins/lua/nvim-cmp.lua
Normal file
114
modules/programs/nvim/plugins/lua/nvim-cmp.lua
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
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 = {
|
||||
Codeium = "",
|
||||
},
|
||||
}),
|
||||
},
|
||||
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(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = {
|
||||
{ name = "async_path", priority = 1 },
|
||||
{ name = "buffer", priority = 1 },
|
||||
{ name = "luasnip", priority = 2 },
|
||||
{ name = "codeium", priority = 3 },
|
||||
{ name = "nvim_lsp", priority = 4 },
|
||||
},
|
||||
})
|
||||
|
||||
-- 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,
|
||||
},
|
||||
})
|
||||
)
|
||||
176
modules/programs/nvim/plugins/lua/nvim-lspconfig.lua
Normal file
176
modules/programs/nvim/plugins/lua/nvim-lspconfig.lua
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
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").register({
|
||||
K = {
|
||||
function()
|
||||
local winid = require("ufo").peekFoldedLinesUnderCursor()
|
||||
if not winid then
|
||||
vim.lsp.buf.hover()
|
||||
end
|
||||
end,
|
||||
"Hover",
|
||||
},
|
||||
["<leader>"] = {
|
||||
l = {
|
||||
name = "lsp",
|
||||
d = { vim.diagnostic.open_float, "Open diagnostic window" },
|
||||
c = { require("actions-preview").code_actions, "Code action", mode = { "v", "n" } },
|
||||
r = {
|
||||
function()
|
||||
return ":IncRename " .. vim.fn.expand("<cword>")
|
||||
end,
|
||||
"Rename",
|
||||
expr = true,
|
||||
},
|
||||
f = {
|
||||
function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end,
|
||||
"Format (lsp)",
|
||||
mode = { "n", "v" },
|
||||
},
|
||||
},
|
||||
t = {
|
||||
l = { lsp_lines.toggle, "LSP lines" },
|
||||
i = {
|
||||
function()
|
||||
vim.lsp.inlay_hint(bufnr, nil)
|
||||
end,
|
||||
"LSP inlay hints",
|
||||
},
|
||||
},
|
||||
},
|
||||
g = {
|
||||
d = {
|
||||
function()
|
||||
require("telescope.builtin").lsp_definitions({ reuse_win = true })
|
||||
end,
|
||||
"Goto definition",
|
||||
},
|
||||
t = {
|
||||
function()
|
||||
require("telescope.builtin").lsp_type_definitions({ reuse_win = true })
|
||||
end,
|
||||
"Goto type defininition",
|
||||
},
|
||||
r = { "<cmd>Telescope lsp_references<cr>", "Goto references" },
|
||||
D = { vim.lsp.buf.declaration, "Goto declaration" },
|
||||
I = { "<cmd>Telescope lsp_implementations<cr>", "Goto implementation" },
|
||||
K = { vim.lsp.buf.signature_help, "Signature help" },
|
||||
},
|
||||
["["] = {
|
||||
d = { vim.diagnostic.goto_prev, "Previous diagnostic" },
|
||||
},
|
||||
["]"] = {
|
||||
d = { vim.diagnostic.goto_next, "Next diagnostic" },
|
||||
},
|
||||
}, { buffer = bufnr, silent = true })
|
||||
|
||||
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(bufnr, true)
|
||||
end, timeout)
|
||||
end
|
||||
|
||||
require("lsp_signature").on_attach({
|
||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||
handler_opts = {
|
||||
border = "rounded",
|
||||
},
|
||||
}, bufnr)
|
||||
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",
|
||||
"nil_ls",
|
||||
"pylsp",
|
||||
"ruff_lsp",
|
||||
"typst_lsp",
|
||||
"gopls",
|
||||
}
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig_setup(lsp, {})
|
||||
end
|
||||
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
require("nvim-treesitter.configs").setup({
|
||||
textsubjects = {
|
||||
enable = true,
|
||||
prev_selection = ",", -- (Optional) keymap to select the previous selection
|
||||
keymaps = { ["."] = "textsubjects-smart" },
|
||||
},
|
||||
})
|
||||
10
modules/programs/nvim/plugins/lua/nvim-treesitter.lua
Normal file
10
modules/programs/nvim/plugins/lua/nvim-treesitter.lua
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
require("nvim-treesitter.configs").setup({
|
||||
sync_install = false,
|
||||
auto_install = false,
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
},
|
||||
})
|
||||
74
modules/programs/nvim/plugins/lua/nvim-ufo.lua
Normal file
74
modules/programs/nvim/plugins/lua/nvim-ufo.lua
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
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" },
|
||||
},
|
||||
})
|
||||
22
modules/programs/nvim/plugins/lua/statuscol-nvim.lua
Normal file
22
modules/programs/nvim/plugins/lua/statuscol-nvim.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
|
||||
local builtin = require("statuscol.builtin")
|
||||
require("statuscol").setup({
|
||||
segments = {
|
||||
{
|
||||
sign = { name = { ".*" }, auto = true },
|
||||
click = "v:lua.ScSa",
|
||||
},
|
||||
{
|
||||
text = { builtin.lnumfunc },
|
||||
click = "v:lua.ScLa",
|
||||
},
|
||||
{
|
||||
sign = { name = { "GitSigns" }, auto = true },
|
||||
click = "v:lua.ScSa",
|
||||
},
|
||||
{
|
||||
text = { builtin.foldfunc, " " },
|
||||
click = "v:lua.ScFa",
|
||||
},
|
||||
},
|
||||
})
|
||||
1
modules/programs/nvim/plugins/lua/telescope.lua
Normal file
1
modules/programs/nvim/plugins/lua/telescope.lua
Normal file
|
|
@ -0,0 +1 @@
|
|||
require("telescope").load_extension("fzf")
|
||||
2
modules/programs/nvim/plugins/lua/vim-startuptime.lua
Normal file
2
modules/programs/nvim/plugins/lua/vim-startuptime.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
vim.g.startuptime_tries = 10
|
||||
vim.g.startuptime_exe_path = "vim"
|
||||
63
modules/programs/nvim/plugins/lua/which-key-nvim.lua
Normal file
63
modules/programs/nvim/plugins/lua/which-key-nvim.lua
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
vim.o.timeout = true
|
||||
vim.o.timeoutlen = 500
|
||||
|
||||
-- Delete
|
||||
require("which-key").register({
|
||||
d = {
|
||||
name = "delete",
|
||||
b = { "<cmd>bd<cr>", "Delete buffer" },
|
||||
w = { "<C-w>c", "Delete window" },
|
||||
},
|
||||
}, { prefix = "<leader>" })
|
||||
|
||||
-- buffer
|
||||
require("which-key").register({
|
||||
["["] = {
|
||||
b = { "<cmd>bprevious<cr>", "Previous buffer" },
|
||||
},
|
||||
["]"] = {
|
||||
b = { "<cmd>bnext<cr>", "Next buffer" },
|
||||
},
|
||||
})
|
||||
|
||||
-- window
|
||||
require("which-key").register({
|
||||
w = {
|
||||
name = "window",
|
||||
["|"] = { "<C-w>v", "Split window horizontally" },
|
||||
["-"] = { "<C-w>s", "Split window vertically" },
|
||||
w = { "<C-w>w", "Switch window" },
|
||||
},
|
||||
}, { prefix = "<leader>" })
|
||||
|
||||
-- better descriptions for navigation
|
||||
require("which-key").register({
|
||||
["<leader>"] = {
|
||||
f = { name = "file/find" },
|
||||
g = { name = "git" },
|
||||
l = { name = "lsp" },
|
||||
o = { name = "org" },
|
||||
s = { name = "search" },
|
||||
t = { name = "toggle" },
|
||||
x = { name = "diagnostics/quickfix" },
|
||||
},
|
||||
["["] = { name = "prev" },
|
||||
["]"] = { name = "next" },
|
||||
g = { name = "goto" },
|
||||
})
|
||||
|
||||
-- Clear search with <esc>
|
||||
require("which-key").register({
|
||||
["<esc>"] = { "<cmd>noh<cr><esc>", "Escape and clear hlsearch", mode = { "n", "i" } },
|
||||
})
|
||||
|
||||
-- better indenting
|
||||
require("which-key").register({
|
||||
["<"] = { "<gv", "Shift left" },
|
||||
[">"] = { ">gv", "Shift right" },
|
||||
}, { mode = "v" })
|
||||
|
||||
-- better yank in visual mode
|
||||
require("which-key").register({
|
||||
y = { "ygv<esc>", "Yank" },
|
||||
}, { mode = "v" })
|
||||
27
modules/programs/nvim/plugins/lua/zettelkasten-nvim.lua
Normal file
27
modules/programs/nvim/plugins/lua/zettelkasten-nvim.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
local telekasten = require("telekasten")
|
||||
telekasten.setup({
|
||||
home = vim.fn.expand("~/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,
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue