nvim fix go indention

This commit is contained in:
thek4n 2024-11-21 13:33:55 +03:00
parent 9d43f6262d
commit 7f217ecbd7
3 changed files with 10 additions and 25 deletions

View File

@ -0,0 +1,5 @@
local opt = vim.opt_local
opt.expandtab = false
opt.tabstop = 4
opt.shiftwidth = 4

View File

@ -4,27 +4,4 @@ vim.g.python_indent = {
continue = 'shiftwidth()', continue = 'shiftwidth()',
closed_paren_align_last_line = false, closed_paren_align_last_line = false,
searchpair_timeout = 150, searchpair_timeout = 150,
} }
vim.api.nvim_create_autocmd("InsertCharPre", {
pattern = { "*.py" },
group = vim.api.nvim_create_augroup("py-fstring", { clear = true }),
---@param params NvimAutocmdCallbackParams
callback = function(params)
if vim.v.char ~= "{" then return end
local node = vim.treesitter.get_node({})
if not node then return end
if node:type() ~= "string" then node = node:parent() end
if not node or node:type() ~= "string" then return end
local row, col, _, _ = vim.treesitter.get_node_range(node)
local first_char = vim.api.nvim_buf_get_text(params.buf, row, col, row, col + 1, {})[1]
if first_char == "f" then return end
vim.api.nvim_input("<Esc>m'" .. row + 1 .. "gg" .. col + 1 .. "|if<esc>`'la")
end,
})

View File

@ -22,4 +22,7 @@ indent_size = tab
tab_width = 4 tab_width = 4
[*.json] [*.json]
insert_final_newline = true insert_final_newline = true
[*.go]
indent_style = tab