Neovim自动缩进消失问题咨询及相关配置说明
问题:Neovim空行缩进丢失与Tab键映射需求
- 近期从Sublime Text切换到Neovim,键盘操作不熟练,常在插入模式用鼠标编辑代码
- 按下Enter换行时光标自动缩进,但未输入内容就移开光标后,再通过箭头键或鼠标返回该行,光标回到行首,缩进消失,需重新按退格再按Enter恢复
- 将插入模式下的
<tab>映射为<right>,因为键盘上的<right>键位置过远 - 尝试用nvim-treesitter解决缩进问题但无效
options.lua
vim.cmd("let g:netrw_banner=0") vim.opt.foldmethod = "expr" vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.opt.foldtext = "" vim.opt.foldlevel = 99 vim.opt.foldlevelstart = 1 vim.opt.foldnestmax = 4 vim.opt.nu=true vim.opt.tabstop=4 vim.opt.shiftwidth=4 vim.opt.autoindent=true vim.opt.smartindent=true vim.opt.wrap=false vim.opt.swapfile=false vim.opt.backup=false vim.opt.undofile=true vim.opt.incsearch=true vim.opt.inccommand="split" vim.opt.ignorecase=true vim.opt.smartcase=true vim.opt.termguicolors = true vim.opt.background = "dark" vim.opt.scrolloff = 4 vim.opt.signcolumn = "yes" vim.opt.backspace = { "start", "eol", "indent" } vim.opt.splitright = true vim.opt.splitbelow = true vim.opt.updatetime = 50 vim.opt.colorcolumn = "80" vim.opt.clipboard:append("unnamedplus") vim.opt.hlsearch = true vim.opt.mouse = "a" vim.g.editorconfig = true
treesitter.lua
return { { "nvim-treesitter/nvim-treesitter", event = { "BufReadPre", "BufNewFile" }, build = ":TSUpdate", config = function() local treesitter = require("nvim-treesitter.configs") treesitter.setup({ highlight = { enable = true }, indent = { enable = true }, ensure_installed = { "json","javascript","typescript","tsx","go","yaml", "html","css","python","http","prisma","markdown", "markdown_inline","svelte","graphql","bash","lua", "vim","dockerfile","gitignore","query","vimdoc", "c","java","rust" }, incremental_selection = { enable = true, keymaps = { init_selection = "<C-space>", node_incremental = "<C-space>", scope_incremental = false } }, additional_vim_regex_highlighting = false }) end } }
内容的提问来源于stack exchange,提问作者Atharva Gulve
相关产品推荐
相关产品推荐

