Ccmmutty logo
Commutty IT
3 min read

Neovim 40個のおすすめオプション

https://cdn.magicode.io/media/notebox/f576011c-280a-42ff-9016-533387ba8f59.jpeg

概要

  • Neovimのオプションの設定例を紹介します.
  • Luaで新しく設定を書く方の一助になればと思います.

注意

  • デフォルトでオンになっているオプション(wildmenu等)は除いています.
  • おすすめなオプションがあれば暇だったら教えてください.
  • おかしな点があれば下のコメントで注意していただけると幸いです.

バージョン

$ nvim --version
NVIM v0.8.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

各オプションの調べ方

:h 'option名'

設定

opt.lua
local indent = 4
return {
  fenc = "utf-8",
  backup = false,
  swapfile = false,
  autoread = true,
  tabstop = indent,
  shiftwidth = indent,
  softtabstop = indent,
  expandtab = true,
  autoindent = true,
  number = true,
  relativenumber = true,
  winbar = "%f",
  scrolloff = 10,
  cursorline = true,
  incsearch = true,
  termguicolors = true,
  background = "dark",
  mouse = "a",
  t_8f = "^[[38;2;%lu;%lu;%lum",
  t_8b = "^[[48;2;%lu;%lu;%lum",
  list = true,
  listchars = "tab:\194\187-, trail:\226\150\161",
  spell = true,
  ignorecase = true,
  smartcase = true,
  startofline = true,
  spelllang = "en, cjk",
  -- guifont = "HackGen Console", -- OPTION
  inccommand = "split",
  equalalways = false,
  laststatus = 3,
  -- cmdheight = 0 -- OPTION
  history = 1000,
  ttimeout = true,
  ttimeoutlen = 100,
  confirm = true
  lazyredraw = true
  -- showmode = false -- OPTION 
  -- splitright = true -- OPTION
}
init.lua
for key, val in pairs(require("opt")) do
  vim.o[key] = val
end

-- undo
if vim.fn.has("persistent_undo") then
  local target_path = vim.fn.expand("~/.local/share/nvim/undo")
  if not vim.fn.isdirectory(target_path) then
    vim.fn.mkdir(target_path, "p", 700)
  else
  end
  vim.o["undodir"] = target_path
  vim.o["undofile"] = true
  return nil
else
  return nil
end

-- command
for _, val in ipairs(["lang en_US.UTf-8"
                      "filetype plugin indent on"
                      "syntax on"
                      "set clipboard+=unnamed"
                      -- "set iskeyword-=_" -- OPTION
]) do
  vim.cmd(val)
end

Discussion

コメントにはログインが必要です。