au FileType python let b:coc_root_patterns = ['.git', '.env', 'venv', '.venv', 'setup.cfg', 'setup.py', 'pyrightconfig.json']
I guess not many people using this config with neovim.
au FileType python let b:coc_root_patterns = ['.git', '.env', 'venv', '.venv', 'setup.cfg', 'setup.py', 'pyrightconfig.json']
I guess not many people using this config with neovim.
If you are using nvim 0.7 or later, there is now native Lua api nvim_create_autocmd
for this.
local api = vim.api
api.nvim_create_autocmd({'FileType'},
pattern = 'python',
callback = function()
vim.b.coc_root_patterns = {'.git', '.env', 'venv', '.venv', 'setup.cfg', 'setup.py', 'pyrightconfig.json'}
end
)
The equivalent for vim script b:xxx
variable is vim.b
in Lua, see also :help vim.b
for more info.
I think it should be like this.
local group = vim.api.nvim_create_augroup('coc_root', { clear = true })
local events = { 'FileType' }
vim.api.nvim_create_autocmd( events, {
pattern = 'python',
callback = function()
vim.bo.coc_root_patterns = { '.git', '.env', 'venv', '.venv', 'setup.cfg', 'setup.py', 'pyrightconfig.json' }
end,
group = group,
})
I really did not test it, let me know if it does not work.
See:
:help nvim_command
Than you can do...
Check afterwards in nvim command mode:
:au FileType