nvim 整備を再開。 v0.9.0-dev Windows10, WSL 共用設定で運用。

LSP も含めて整ってきたので、久しぶりに vscode から出られそうな予感。

ある程度の環境ができあがるまで、無限に寄り道を強いられるので なかなか本筋に集中できなくなるが、できあがると快適に。 現状の環境に付いてメモをしておく。

term + font

  • WslTty + HackGenNerd + tmux
  • WezTerm + HackGenNerd(tmux なし。wezterm を使う)

init.lua

lua ファイルの配置

~/.config/nvim/luaLUA_PATH になるので のフォルダに普通の lua モジュール の流儀で配置して、 reqiure できるようにする。

-- ~/.config/nvim/lua/dot.lua
-- module
local M={}
M.value = 1
function M.hello()
print('hello')
end
return M
-- use
require('dot').hello()

keymap

nvim の場合いくつか指定方法があるのだが、 lua の vim.keymap.set 関数がよい。 lua の関数を直接指定できるので快適。

vim.keymap.set('n', '<Space>a', '<cmd>LspInfo<CR>')
-- lua の関数も書ける
vim.keymap.set('n', '<Space>a', function()
print('hello lua')
end)

Windows での border 手動設定

Windows では telescope とかの罫線が文字化けしてしまうのだが、 文字列で指定すると問題が無いことがわかった。 どうも、エスケープシーケンスで罫線出力したときに Windows の conpty で変換されて 壊れるような気がしている。 なので、設定で unicode などの文字で罫線を指定してやると綺麗に描画される様子。

-- border 指定。
dot.border = {
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
}
-- plugin ごとにこまめに設定してやる
-- LspInfo など
require("lspconfig.ui.windows").default_options.border = dot.border
-- nvim-cmp
cmp.setup {
window = {
completion = cmp.config.window.bordered {
border = dot.border,
},
documentation = cmp.config.window.bordered {
border = dot.border,
},
},

で、罫線があると completion とか floating window の見栄えがよろしいのですな。

Windows はまだ描画が乱れる場合はあるのだけど、 左サイドに NvimTree を出しっぱなしにするなどで、ある程度防御できる、ぽい。

package manager

lazy

comment

telescope

packer から乗り換え。

nvimtree

NerdTree から乗り換え。

treesitter

lspconfig

いろいろ設定項目があるので、少しずつやる。

  1. lua_ls + neodev
  2. formatter
  3. diagnostics / hover
  4. semantic symbol => aerial, syntax highlight
  5. goto defintion => tjump
  6. completion

languages

lua_ls, clangd, pyright, tsserver(gatsby 作業), omnisharp(Unity 作業), gopls, jsonls あたり快適に使えている。 一部、 ~/.vscode-server/extensions のバイナリ使ってます。すいません。

lua_ls

neodev で nvim の builtin 関数の情報を表示する。

clangd

header / source 切りかえ。A.vim みたいなやつ。 ClangdSwitchSourceHeader

lualine

aerial

completion

cmp

lsp 経由の formatter

だいたい、 LanguageServer に任せてしまえる。 lua_ls と stylua を組みあわせたい場合など、別のフォーマッターを使いたい場合は lua_ls のフォーマッターを停止させつつ、 null-ls の stylua を使うことができた。

git

quickfix

タスクランナーを使うのをやめて、下記のサイトを参考にした async_make 的な lua 関数で運用中。 必要に応じて set makeprg=cmake\ --build\ build などする。

Asynchronous :make in Neovim with Lua
The :make command in Vim is quite useful, it runs whatever program is under the makeprg option and returns its output in the quickfix list, where you’ll be able to hop through the errors if they were parsed correctly by the errorformat option.
Asynchronous :make in Neovim with Lua favicon https://phelipetls.github.io/posts/async-make-in-nvim-with-lua/
Asynchronous :make in Neovim with Lua

Cfilter で件数を絞って <Tab>, <S-Tab> で quickfix を巡回するように設定した。 quickfix の新旧リスト切り替えを <C-n>, <C-p> にわりあてて、 使い捨ての quickfix を量産する感じに(c++)。

floating term

skk

LuaSnip

TODO:

LanguageServer は完全に実用になった。 DebugAdapter は動くけど、快適でない感じがする。