Open6
coc.nvim から nvim-cmp へ
- snipetsはsnipmate系のものを使いたい
cocを使っていた最大の理由 > snipmate系 - LSPも移行する(色々変わった模様)
- Copilot
使用していた extension -> 代替
- coc-explorer -> nvim-tree.lua
- coc-fzf-preview -> nvim-tree-preview
- coc-go
- coc-snippets -> cmp-snippy, nvim-snippy
- coc-sh -> bashls, shfmt, shellchek
- coc-pyright -> pyright, ruff
- coc-yaml -> yamlls, yamlfmt, yamllint
- coc-json -> jsonls, jsonlint
- coc-html
- coc-tsserver -> ts_ls, eslint_d, prettier
- coc-css -> cssls, stylelint, prettier
- coc-html-css-support
- @yaegassy/coc-intelephense -> intelephense
- coc-sumneko-lua -> lua_ls
- @hexuhua/coc-copilot -> copilot.lua and copilot-cmp
試してみたい cmp
- dcampos/cmp-emmet-vim: emmet-vim completion source for nvim-cmp.
- hrsh7th/nvim-pasta: The yank/paste enhancement plugin for neovim.
その他試したい
- avante.nvim
前提:
プラグインマネージャーは jetpack の packer
TODO:
coc の設定をコメントアウト
-- {
-- 'neoclide/coc.nvim',
-- branch = 'release',
-- config = function()
-- require('plugins.coc')
-- end
-- },
Neovim + nvim-cmp で snipmate 形式のスニペットを使いたい場合は以下のプラグインを使用する。
{
'hrsh7th/nvim-cmp',
requires = {
'dcampos/nvim-snippy',
'dcampos/cmp-snippy',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline'
},
config = function()
require('plugins.nvim-cmp')
end
},
設定
~/.config/nvim/lua/plugins/nvim-cmp.lua
vim.g.vsnip_snippet_dir = os.getenv('HOME')..'/.config/nvim/snippets'
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local snippy = require("snippy")
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require("snippy").expand_snippet(args.body)
end,
},
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "snippy" },
{ name = "buffer" },
{ name = "path" },
{ name = "cmdline" },
}),
mapping = {
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif snippy.can_expand_or_advance() then
snippy.expand_or_advance()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif snippy.can_jump(-1) then
snippy.previous()
else
fallback()
end
end, { "i", "s" }),
},
})
copilot.lua
が動作しなかったが、~/.config/github-copilot
を削除して、再認証したら動作するようになった。