Nvim cleanup.

This commit is contained in:
2026-05-09 07:31:53 +02:00
parent e6dea46ab1
commit d9eb45790b
3 changed files with 58 additions and 31 deletions
+1
View File
@@ -24,6 +24,7 @@ vim.o.splitright = true -- Open vertical splits to the right
vim.o.splitbelow = true -- Open horizontal splits below vim.o.splitbelow = true -- Open horizontal splits below
vim.o.timeoutlen = 300 -- Time (ms) to wait for a mapped sequence to complete vim.o.timeoutlen = 300 -- Time (ms) to wait for a mapped sequence to complete
vim.o.autocomplete = true vim.o.autocomplete = true
vim.o.showmode = false
vim.opt.clipboard = "unnamedplus" vim.opt.clipboard = "unnamedplus"
vim.o.completeopt = 'menuone,noselect' vim.o.completeopt = 'menuone,noselect'
vim.o.undodir = os.getenv("HOME") .. "/.cache/nvim/undodir" vim.o.undodir = os.getenv("HOME") .. "/.cache/nvim/undodir"
+30 -31
View File
@@ -6,7 +6,6 @@ vim.api.nvim_create_autocmd('FileType', {
pattern = '*', pattern = '*',
callback = function() callback = function()
pcall(vim.treesitter.start) pcall(vim.treesitter.start)
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end, end,
}) })
@@ -56,9 +55,9 @@ vim.api.nvim_create_autocmd('LspAttach', {
-- Enable completion if the server supports it -- Enable completion if the server supports it
if client:supports_method('textDocument/completion') then if client:supports_method('textDocument/completion') then
vim.lsp.completion.enable(true, client.id, ev.buf, { vim.lsp.completion.enable(true, client.id, ev.buf, {
autotrigger = true, -- false = manual trigger only autotrigger = true, -- false = manual trigger only
}) })
end end
end, end,
}) })
@@ -87,37 +86,37 @@ vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, {
-- Format: whole file or visual selection via :Fc -- Format: whole file or visual selection via :Fc
local function smart_format() local function smart_format()
local mode = vim.fn.mode() local mode = vim.fn.mode()
local in_visual = mode == "v" or mode == "V" or mode == "\22" local in_visual = mode == "v" or mode == "V" or mode == "\22"
local clients = vim.lsp.get_clients({ bufnr = 0 }) local clients = vim.lsp.get_clients({ bufnr = 0 })
local has_formatter = false local has_formatter = false
for _, client in ipairs(clients) do for _, client in ipairs(clients) do
if client.supports_method("textDocument/formatting") then if client.supports_method("textDocument/formatting") then
has_formatter = true has_formatter = true
break break
end
end end
end
if in_visual then if in_visual then
if has_formatter then if has_formatter then
vim.lsp.buf.format({ vim.lsp.buf.format({
range = { range = {
start = vim.api.nvim_buf_get_mark(0, "<"), start = vim.api.nvim_buf_get_mark(0, "<"),
["end"] = vim.api.nvim_buf_get_mark(0, ">"), ["end"] = vim.api.nvim_buf_get_mark(0, ">"),
}, },
}) })
else
vim.cmd("normal! gv=")
end
else else
vim.cmd("normal! gv=") if has_formatter then
vim.lsp.buf.format({ async = false })
else
local view = vim.fn.winsaveview()
vim.cmd("normal! gg=G")
vim.fn.winrestview(view)
end
end end
else
if has_formatter then
vim.lsp.buf.format({ async = false })
else
local view = vim.fn.winsaveview()
vim.cmd("normal! gg=G")
vim.fn.winrestview(view)
end
end
end end
vim.api.nvim_create_user_command("FF", smart_format, { range = true }) vim.api.nvim_create_user_command("FF", smart_format, { range = true })
+27
View File
@@ -4,10 +4,37 @@ vim.pack.add({
{ src = "https://github.com/romus204/tree-sitter-manager.nvim" }, { src = "https://github.com/romus204/tree-sitter-manager.nvim" },
{ src = "https://github.com/rebelot/kanagawa.nvim" }, { src = "https://github.com/rebelot/kanagawa.nvim" },
{ src = "https://github.com/tribela/transparent.nvim" }, { src = "https://github.com/tribela/transparent.nvim" },
{ src = "https://github.com/nvim-lualine/lualine.nvim" }
}) })
vim.cmd(":colorscheme kanagawa") vim.cmd(":colorscheme kanagawa")
require("tree-sitter-manager").setup({}) require("tree-sitter-manager").setup({})
local theme = require('lualine.themes.kanagawa')
for _, mode in pairs(theme) do
if mode.b then mode.b.bg = '#16161D' end
if mode.c then mode.c.bg = '#16161D' end
if mode.x then mode.x.bg = '#16161D' end
if mode.y then mode.y.bg = '#16161D' end
if mode.z then mode.z.bg = '#16161D' end
end
require('lualine').setup({
options = {
theme = theme,
component_separators = '',
section_separators = '',
},
sections = {
lualine_a = {'mode'},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'diagnostics'},
lualine_y = {},
lualine_z = {'lsp_status', 'location'},
},
})
require("fzf-lua").setup() require("fzf-lua").setup()
map("n", "<leader>f", ":lua FzfLua.files()<CR>") map("n", "<leader>f", ":lua FzfLua.files()<CR>")