chore(home-manager): put neovim plugins configuration in a separate directory
This commit is contained in:
parent
a8c87655ac
commit
d9aecb3e19
16 changed files with 13 additions and 84 deletions
98
modules/home-manager/cli/neovim/files/plugins/cmp.lua
Normal file
98
modules/home-manager/cli/neovim/files/plugins/cmp.lua
Normal file
|
@ -0,0 +1,98 @@
|
|||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(
|
||||
0,
|
||||
line - 1,
|
||||
line,
|
||||
true
|
||||
)[1]:sub(col, col):match('%s') == nil
|
||||
end
|
||||
|
||||
local get_ws = function (max, len)
|
||||
return (" "):rep(max - len)
|
||||
end
|
||||
|
||||
-- Add additional capabilities supported by nvim-cmp
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local luasnip = require("luasnip")
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
-- nvim-cmp setup
|
||||
local cmp = require 'cmp'
|
||||
cmp.setup {
|
||||
mapping = {
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
||||
-- they way you will only jump inside the snippet region
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
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" }),
|
||||
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}),
|
||||
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}),
|
||||
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), {'i', 'c'}),
|
||||
["<C-e>"] = cmp.mapping({ i = cmp.mapping.close(), c = cmp.mapping.close() }),
|
||||
},
|
||||
formatting = {
|
||||
format = function(_, vim_item)
|
||||
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
|
||||
|
||||
local content = vim_item.abbr
|
||||
if #content > 25 then
|
||||
vim_item.abbr = vim.fn.strcharpart(content, 0, 25) .. "…"
|
||||
else
|
||||
vim_item.abbr = content .. get_ws(25, #content)
|
||||
end
|
||||
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{name = 'path'},
|
||||
{name = 'nvim_lsp', keyword_length = 1},
|
||||
{name = 'buffer', keyword_length = 3},
|
||||
{name = 'luasnip', keyword_length = 2},
|
||||
},
|
||||
}
|
12
modules/home-manager/cli/neovim/files/plugins/conform.lua
Normal file
12
modules/home-manager/cli/neovim/files/plugins/conform.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
require("conform").setup({
|
||||
format_on_save = {
|
||||
-- These options will be passed to conform.format()
|
||||
timeout_ms = 500,
|
||||
lsp_format = "never",
|
||||
},
|
||||
formatters_by_ft = {
|
||||
yaml = {"yamlfmt"},
|
||||
sh = { "shfmt" },
|
||||
["_"] = { "trim_whitespace" },
|
||||
}
|
||||
})
|
41
modules/home-manager/cli/neovim/files/plugins/fzf-lua.lua
Normal file
41
modules/home-manager/cli/neovim/files/plugins/fzf-lua.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
require('fzf-lua').setup({
|
||||
previewers = {
|
||||
builtin = {
|
||||
extensions = {
|
||||
['png'] = { "chafa" },
|
||||
['jpg'] = { "chafa" },
|
||||
['svg'] = { "chafa" },
|
||||
}
|
||||
}
|
||||
},
|
||||
files = {
|
||||
cwd_prompt_shorten_len = 20
|
||||
}
|
||||
})
|
||||
|
||||
-- Register fzf-lua as vim.ui.select handler
|
||||
require('fzf-lua').register_ui_select({
|
||||
prompt = 'Make a selection:',
|
||||
format_item = function(item)
|
||||
return "-> " .. tostring(item)
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set('n', '<leader>fb', function() require('fzf-lua').buffers() end, {desc='open [b]uffers'})
|
||||
vim.keymap.set('n', '<leader>ff', function() require('fzf-lua').files() end, {desc='[r]esume last command'})
|
||||
vim.keymap.set('n', '<leader>fr', function() require('fzf-lua').files() end, {desc='[f]iles'})
|
||||
|
||||
-- git related keymaps
|
||||
vim.keymap.set('n', '<leader>fgb', function() require('fzf-lua').git_branches() end, {desc='Git [b]ranches'})
|
||||
vim.keymap.set('n', '<leader>fgc', function() require('fzf-lua').git_commits() end, {desc='Git [c]ommits'})
|
||||
vim.keymap.set('n', '<leader>fgC', function() require('fzf-lua').git_bcommits() end, {desc='Git current buffer [C]ommits'})
|
||||
vim.keymap.set('n', '<leader>fgf', function() require('fzf-lua').git_files() end, {desc='Git [f]iles'})
|
||||
vim.keymap.set('n', '<leader>fgs', function() require('fzf-lua').git_stash() end, {desc='Git [s]tash'})
|
||||
vim.keymap.set('n', '<leader>fgS', function() require('fzf-lua').git_status() end, {desc='Git [S]tash'})
|
||||
|
||||
-- grep related keymaps
|
||||
vim.keymap.set('n', '<leader>fGb', function() require('fzf-lua').grep_curbuf() end, {desc='grep in current [b]uffer'})
|
||||
vim.keymap.set('n', '<leader>fGc', function() require('fzf-lua').grep_cword() end, {desc='grep word under the [c]ursor'})
|
||||
vim.keymap.set('n', '<leader>fGg', function() require('fzf-lua').grep() end, {desc='[g]rep'})
|
||||
vim.keymap.set('n', '<leader>fGl', function() require('fzf-lua').live_grep() end, {desc='[l]ive grep'})
|
||||
vim.keymap.set('n', '<leader>fGr', function() require('fzf-lua').grep_last() end, {desc='[r]erun last grep'})
|
35
modules/home-manager/cli/neovim/files/plugins/lualine.lua
Normal file
35
modules/home-manager/cli/neovim/files/plugins/lualine.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
require('lualine').setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'catppuccin',
|
||||
component_separators = { left = '|', right = '|'},
|
||||
section_separators = { left = "", right = ""},
|
||||
disabled_filetypes = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = true,
|
||||
-- reduce performance impact reducing refresh pace
|
||||
refresh = {
|
||||
statusline = 1500,
|
||||
tabline = 1500,
|
||||
winbar = 1500,
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_y = {'progress'},
|
||||
lualine_z = {'location'}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'location'},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {}
|
||||
}
|
29
modules/home-manager/cli/neovim/files/plugins/luasnip.lua
Normal file
29
modules/home-manager/cli/neovim/files/plugins/luasnip.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
require('gitsigns').setup {
|
||||
on_attach = function(bufnr)
|
||||
local gs = package.loaded.gitsigns
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map('n', '<leader>gn', function()
|
||||
if vim.wo.diff then return ']c' end
|
||||
vim.schedule(function() gs.next_hunk() end)
|
||||
return '<Ignore>'
|
||||
end, {expr=true})
|
||||
|
||||
map('n', '<leader>gN', function()
|
||||
if vim.wo.diff then return '[c' end
|
||||
vim.schedule(function() gs.prev_hunk() end)
|
||||
return '<Ignore>'
|
||||
end, {expr=true})
|
||||
|
||||
map('n', '<leader>gs', gs.stage_hunk)
|
||||
map('n', '<leader>gr', gs.reset_hunk)
|
||||
map('n', '<leader>gd', gs.diffthis)
|
||||
map('n', '<leader>gd', function() gs.diffthis('~') end)
|
||||
end
|
||||
}
|
20
modules/home-manager/cli/neovim/files/plugins/neotree.lua
Normal file
20
modules/home-manager/cli/neovim/files/plugins/neotree.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
local neotree = require 'neo-tree'
|
||||
neotree.setup({
|
||||
close_if_last_window = true,
|
||||
filesystem = {
|
||||
filtered_items = {
|
||||
-- when true, they will just be displayed differently
|
||||
-- than normal items
|
||||
visible = false,
|
||||
hide_dotfiles = false,
|
||||
hide_gitignored = true,
|
||||
},
|
||||
follow_current_file = {
|
||||
-- follow file in current buffer even iof the file is
|
||||
-- loaded while tree is open
|
||||
enabled = true,
|
||||
-- do not autoclose expanded dirs
|
||||
leave_dirs_open = true,
|
||||
},
|
||||
}
|
||||
})
|
|
@ -0,0 +1,6 @@
|
|||
require("nvim-k8s-lsp").setup({
|
||||
kubernetes_version = "v1.32.2",
|
||||
integrations = {
|
||||
lualine = false,
|
||||
}
|
||||
})
|
|
@ -0,0 +1,9 @@
|
|||
require('lint').linters_by_ft = {
|
||||
dockerfile = {'hadolint',}
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
callback = function()
|
||||
require("lint").try_lint()
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,4 @@
|
|||
require('nvim_sops').setup {}
|
||||
|
||||
vim.keymap.set("n", "<leader>se", vim.cmd.SopsEncrypt, { desc = "Sops: [E]ncrypt file" })
|
||||
vim.keymap.set("n", "<leader>sd", vim.cmd.SopsDecrypt, { desc = "Sops: [D]ecrypt file" })
|
7
modules/home-manager/cli/neovim/files/plugins/theme.lua
Normal file
7
modules/home-manager/cli/neovim/files/plugins/theme.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
require("catppuccin").setup {
|
||||
integrations = {
|
||||
neotree = true
|
||||
}
|
||||
}
|
||||
vim.opt.termguicolors = true -- 24 bits color support
|
||||
vim.cmd.colorscheme "catppuccin"
|
10
modules/home-manager/cli/neovim/files/plugins/treesitter.lua
Normal file
10
modules/home-manager/cli/neovim/files/plugins/treesitter.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
-- Tree sitter
|
||||
--
|
||||
local ts = require 'nvim-treesitter.configs'
|
||||
|
||||
ts.setup {
|
||||
sync_install = false,
|
||||
highlight = {
|
||||
enable = true,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
require('treesitter-context').setup{
|
||||
enable = true,
|
||||
max_lines = 7,
|
||||
min_window_height = 0,
|
||||
line_numbers = true,
|
||||
multiline_threshold = 4,
|
||||
trim_scope = 'outer',
|
||||
mode = 'cursor',
|
||||
separator = nil,
|
||||
zindex = 20,
|
||||
on_attach = nil,
|
||||
}
|
10
modules/home-manager/cli/neovim/files/plugins/whichkey.lua
Normal file
10
modules/home-manager/cli/neovim/files/plugins/whichkey.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
-- Which-key
|
||||
--
|
||||
local wk = require 'which-key'
|
||||
wk.add({
|
||||
{'<leader>n', group = 'NeoTree'},
|
||||
{'<leader>f', group = 'fzf-lua'},
|
||||
{'<leader>fg', group = 'fzf-lua Git'},
|
||||
{'<leader>fG', group = 'fzf-lua Grep'},
|
||||
{'<leader>g', group = 'Gitsign'},
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue