refactor + fmt

This commit is contained in:
2026-04-26 18:06:10 +02:00
parent 56243dacb3
commit 5acc1a8804
31 changed files with 546 additions and 933 deletions
+10
View File
@@ -0,0 +1,10 @@
-- autopairs
-- https://github.com/windwp/nvim-autopairs
---@module 'lazy'
---@type LazySpec
return {
'windwp/nvim-autopairs',
event = 'InsertEnter',
opts = {},
}
+45
View File
@@ -0,0 +1,45 @@
---@module 'lazy'
---@type LazySpec
return {
'saghen/blink.cmp',
event = 'VimEnter',
version = '1.*',
dependencies = {
{
'L3MON4D3/LuaSnip',
version = '2.*',
build = (function()
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then return end
return 'make install_jsregexp'
end)(),
dependencies = {
-- {
-- 'rafamadriz/friendly-snippets',
-- config = function()
-- require('luasnip.loaders.from_vscode').lazy_load()
-- end,
-- },
},
opts = {},
},
},
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
keymap = {
preset = 'default',
},
appearance = {
nerd_font_variant = 'mono',
},
completion = {
documentation = { auto_show = false, auto_show_delay_ms = 500 },
},
sources = {
default = { 'lsp', 'path', 'snippets' },
},
snippets = { preset = 'luasnip' },
fuzzy = { implementation = 'lua' },
signature = { enabled = true },
},
}
+35
View File
@@ -0,0 +1,35 @@
---@module 'lazy'
---@type LazySpec
return {
'stevearc/conform.nvim',
event = { 'BufWritePre' },
cmd = { 'ConformInfo' },
keys = {
{
'<leader>f',
function() require('conform').format { async = true } end,
mode = '',
desc = '[F]ormat buffer',
},
},
---@module 'conform'
---@type conform.setupOpts
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
local enabled_filetypes = {
-- lua = true,
-- python = true,
}
if enabled_filetypes[vim.bo[bufnr].filetype] then return { timeout_ms = 500 } end
return nil
end,
default_format_opts = {
lsp_format = 'fallback',
},
formatters_by_ft = {
-- rust = { 'rustfmt' },
-- python = { "isort", "black" },
},
},
}
+3
View File
@@ -0,0 +1,3 @@
---@module 'lazy'
---@type LazySpec
return { 'tpope/vim-fugitive' }
+17
View File
@@ -0,0 +1,17 @@
---@module 'lazy'
---@type LazySpec
return {
'lewis6991/gitsigns.nvim',
---@module 'gitsigns'
---@type Gitsigns.Config
---@diagnostic disable-next-line: missing-fields
opts = {
signs = {
add = { text = '' }, ---@diagnostic disable-line: missing-fields
change = { text = '' }, ---@diagnostic disable-line: missing-fields
delete = { text = '' }, ---@diagnostic disable-line: missing-fields
topdelete = { text = '' }, ---@diagnostic disable-line: missing-fields
changedelete = { text = '' }, ---@diagnostic disable-line: missing-fields
},
},
}
+3
View File
@@ -0,0 +1,3 @@
---@module 'lazy'
---@type LazySpec
return { 'NMAC427/guess-indent.nvim', opts = {} }
+19
View File
@@ -0,0 +1,19 @@
---@module 'lazy'
---@type LazySpec
return {
require 'plugins.guess-indent',
require 'plugins.gitsigns',
require 'plugins.which-key',
require 'plugins.telescope',
require 'plugins.lsp',
require 'plugins.conform',
require 'plugins.blink',
require 'plugins.tokyonight',
require 'plugins.todo-comments',
require 'plugins.mini',
require 'plugins.treesitter',
require 'plugins.autopairs',
require 'plugins.neo-tree',
require 'plugins.fugitive',
require 'plugins.luasnip',
}
+114
View File
@@ -0,0 +1,114 @@
---@module 'lazy'
---@type LazySpec
return {
'neovim/nvim-lspconfig',
dependencies = {
{
'mason-org/mason.nvim',
---@module 'mason.settings'
---@type MasonSettings
---@diagnostic disable-next-line: missing-fields
opts = {},
},
'mason-org/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
{ 'j-hui/fidget.nvim', opts = {} },
},
config = function()
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
local map = function(keys, func, desc, mode)
mode = mode or 'n'
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
map('grn', vim.lsp.buf.rename, '[R]e[n]ame')
map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client:supports_method('textDocument/documentHighlight', event.buf) then
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.clear_references,
})
vim.api.nvim_create_autocmd('LspDetach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
end,
})
end
if client and client:supports_method('textDocument/inlayHint', event.buf) then
map('<leader>th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints')
end
end,
})
---@type table<string, vim.lsp.Config>
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- ts_ls = {},
stylua = {},
lua_ls = {
on_init = function(client)
client.server_capabilities.documentFormattingProvider = false
if client.workspace_folders then
local path = client.workspace_folders[1].name
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end
end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
runtime = {
version = 'LuaJIT',
path = { '?.lua', '?/init.lua' },
},
workspace = {
checkThirdParty = false,
library = vim.tbl_extend('force', vim.api.nvim_get_runtime_file('', true), {
'${3rd}/luv/library',
'${3rd}/busted/library',
}),
},
})
end,
---@type lspconfig.settings.lua_ls
settings = {
Lua = {
format = { enable = false },
},
},
},
}
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
-- Add other Mason tools here.
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
for name, server in pairs(servers) do
vim.lsp.config(name, server)
vim.lsp.enable(name)
end
end,
}
+11
View File
@@ -0,0 +1,11 @@
---@module 'lazy'
---@type LazySpec
return {
'L3MON4D3/LuaSnip',
config = function(_, opts)
local luasnip = require 'luasnip'
luasnip.config.setup(opts or {})
require 'snippets.cpp'
end,
}
+22
View File
@@ -0,0 +1,22 @@
---@module 'lazy'
---@type LazySpec
return {
'nvim-mini/mini.nvim',
config = function()
require('mini.ai').setup {
mappings = {
around_next = 'aa',
inside_next = 'ii',
},
n_lines = 500,
}
require('mini.surround').setup()
local statusline = require 'mini.statusline'
statusline.setup { use_icons = vim.g.have_nerd_font }
---@diagnostic disable-next-line: duplicate-set-field
statusline.section_location = function() return '%2l:%-2v' end
end,
}
+12
View File
@@ -0,0 +1,12 @@
---@module 'lazy'
---@type LazySpec
return {
'nvim-neo-tree/neo-tree.nvim',
branch = 'v3.x',
dependencies = {
'nvim-lua/plenary.nvim',
'MunifTanjim/nui.nvim',
'nvim-tree/nvim-web-devicons',
},
lazy = false,
}
+80
View File
@@ -0,0 +1,80 @@
---@module 'lazy'
---@type LazySpec
return {
'nvim-telescope/telescope.nvim',
enabled = true,
event = 'VimEnter',
dependencies = {
'nvim-lua/plenary.nvim',
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
cond = function() return vim.fn.executable 'make' == 1 end,
},
{ 'nvim-telescope/telescope-ui-select.nvim' },
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
},
config = function()
require('telescope').setup {
extensions = {
['ui-select'] = { require('telescope.themes').get_dropdown() },
},
}
pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select')
local builtin = require 'telescope.builtin'
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set({ 'n', 'v' }, '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader>sc', builtin.commands, { desc = '[S]earch [C]ommands' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('telescope-lsp-attach', { clear = true }),
callback = function(event)
local buf = event.buf
vim.keymap.set('n', 'grr', builtin.lsp_references, { buffer = buf, desc = '[G]oto [R]eferences' })
vim.keymap.set('n', 'gri', builtin.lsp_implementations, { buffer = buf, desc = '[G]oto [I]mplementation' })
vim.keymap.set('n', 'grd', builtin.lsp_definitions, { buffer = buf, desc = '[G]oto [D]efinition' })
vim.keymap.set('n', 'gO', builtin.lsp_document_symbols, { buffer = buf, desc = 'Open Document Symbols' })
vim.keymap.set('n', 'gW', builtin.lsp_dynamic_workspace_symbols, { buffer = buf, desc = 'Open Workspace Symbols' })
vim.keymap.set('n', 'grt', builtin.lsp_type_definitions, { buffer = buf, desc = '[G]oto [T]ype Definition' })
end,
})
vim.keymap.set(
'n',
'<leader>/',
function()
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end,
{ desc = '[/] Fuzzily search in current buffer' }
)
vim.keymap.set(
'n',
'<leader>s/',
function()
builtin.live_grep {
grep_open_files = true,
prompt_title = 'Live Grep in Open Files',
}
end,
{ desc = '[S]earch [/] in Open Files' }
)
vim.keymap.set('n', '<leader>sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' })
end,
}
+11
View File
@@ -0,0 +1,11 @@
---@module 'lazy'
---@type LazySpec
return {
'folke/todo-comments.nvim',
event = 'VimEnter',
dependencies = { 'nvim-lua/plenary.nvim' },
---@module 'todo-comments'
---@type TodoOptions
---@diagnostic disable-next-line: missing-fields
opts = { signs = false },
}
+16
View File
@@ -0,0 +1,16 @@
---@module 'lazy'
---@type LazySpec
return {
'folke/tokyonight.nvim',
priority = 1000,
config = function()
---@diagnostic disable-next-line: missing-fields
require('tokyonight').setup {
styles = {
comments = { italic = false },
},
}
vim.cmd.colorscheme 'tokyonight-night'
end,
}
+42
View File
@@ -0,0 +1,42 @@
---@module 'lazy'
---@type LazySpec
return {
'nvim-treesitter/nvim-treesitter',
lazy = false,
build = ':TSUpdate',
branch = 'main',
config = function()
local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
require('nvim-treesitter').install(parsers)
---@param buf integer
---@param language string
local function treesitter_try_attach(buf, language)
if not vim.treesitter.language.add(language) then return end
vim.treesitter.start(buf, language)
local has_indent_query = vim.treesitter.query.get(language, 'indents') ~= nil
if has_indent_query then vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end
end
local available_parsers = require('nvim-treesitter').get_available()
vim.api.nvim_create_autocmd('FileType', {
callback = function(args)
local buf, filetype = args.buf, args.match
local language = vim.treesitter.language.get_lang(filetype)
if not language then return end
local installed_parsers = require('nvim-treesitter').get_installed 'parsers'
if vim.tbl_contains(installed_parsers, language) then
treesitter_try_attach(buf, language)
elseif vim.tbl_contains(available_parsers, language) then
require('nvim-treesitter').install(language):await(function() treesitter_try_attach(buf, language) end)
else
treesitter_try_attach(buf, language)
end
end,
})
end,
}
+19
View File
@@ -0,0 +1,19 @@
---@module 'lazy'
---@type LazySpec
return {
'folke/which-key.nvim',
event = 'VimEnter',
---@module 'which-key'
---@type wk.Opts
---@diagnostic disable-next-line: missing-fields
opts = {
delay = 0,
icons = { mappings = vim.g.have_nerd_font },
spec = {
{ '<leader>s', group = '[S]earch', mode = { 'n', 'v' } },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
{ 'gr', group = 'LSP Actions', mode = { 'n' } },
},
},
}