coq_nvim
coq_nvim copied to clipboard
Problem with auto_start
I have previously used completion-nvim
plugin as it is no longer maintained and now hopping to use coq.nvim
.
I'm not able to get the auto_start
working, I have to manually run :COQnow
to get it working.
Can someone help me to see where the problem is?
My lspconfig.rc.vim
if !exists('g:lspconfig')
finish
endif
lua << EOF
local nvim_lsp = require('lspconfig')
local protocol = require('vim.lsp.protocol')
vim.g.coq_settings = {
auto_start = 'shut-up',
}
local coq = require('coq')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- Mappings
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', '<Leader>d', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', '<Leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<Leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<Leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<Leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<Leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
if client.resolved_capabilities.document_formatting then
vim.api.nvim_command [[augroup Format]]
vim.api.nvim_command [[autocmd! * <buffer>]]
vim.api.nvim_command [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
vim.api.nvim_command [[augroup END]]
end
--protocol.SymbolKind = { }
protocol.CompletionItemKind = {
'', -- Text
'', -- Method
'', -- Function
'', -- Constructor
'', -- Field
'', -- Variable
'', -- Class
'ﰮ', -- Interface
'', -- Module
'', -- Property
'', -- Unit
'', -- Value
'', -- Enum
'', -- Keyword
'', -- Snippet
'', -- Color
'', -- File
'', -- Reference
'', -- Folder
'', -- EnumMember
'', -- Constant
'', -- Struct
'', -- Event
'ﬦ', -- Operator
'', -- TypeParameter
}
end
nvim_lsp.tsserver.setup(coq.lsp_ensure_capabilities({
on_attach = on_attach,
filetypes = { "typescript", "typescriptreact", "typescript.tsx" }
}))
EOF
:LspInfo
Language client log: /Users/skipadu/.cache/nvim/lsp.log
Detected filetype: typescriptreact
1 client(s) attached to this buffer:
Client: tsserver (id: 1, pid: 60321, bufnr: [1])
filetypes: javascript, javascriptreact, javascript.jsx, typescript, typescriptreact, typescript.tsx
autostart: true
root directory: /Users/skipadu/project-xyz
cmd: typescript-language-server --stdio
Configured servers list: tsserver
EDIT: Changed the coq.lsp_ensure_capabilities part
I'm just getting started as well, but here is the entirety of my coq.lua
at the moment, and auto_start is working for me:
vim.g.coq_settings = {
keymap = { recommended = false },
auto_start = 'shut-up',
clients = {
tmux = { enabled = false },
},
}
require'coq'
require('coq_3p') {
src = 'nvimlua',
short_name = 'nLUA',
}
Thanks @lyndsysimon for the message, but I can not get it working with that. I changed the settings like the following and every other setting seems to work but not the auto_start
.
vim.g.coq_settings = {
keymap = {
recommended = false,
jump_to_mark = '',
pre_select = true,
},
auto_start = 'shut-up',
clients = {
tmux = { enabled = false },
},
}
Do I have a typo or have I misunderstood the meaning of the auto_start feature alltogether?
I thought that it is meant to auto start COQ so that I do not have to write :COQnow
(or use -- vim.cmd('COQnow -s')
in my config)
As a workaround, I've included an autocmd
to start COQ as soon as Vim does, for the time being until this gets patched.
augroup COQ
autocmd!
autocmd VimEnter * COQnow -s
augroup END
As a workaround, I've included an
autocmd
to start COQ as soon as Vim does, for the time being until this gets patched.augroup COQ autocmd! autocmd VimEnter * COQnow -s augroup END
I've had this problem when i was trying to setup via lua and ended up using vimscript. Just now i tried again and moved the call to coq before the lsp servers setup and it worked fine.
but, for example if i change it to
require('rmc.lsp')
require('rmc.coq')
it won't startup anymore
try a naked vimrc without anything except:
vim.g.coq_settings = { auto_start = true }
require "coq"
This is the minimum for autostart.
Unless there is some new package manager that coq
won't work with I don't see whats there to be patched.
coq
is tested with both rtp
and pack
style managers.
please give me a vimrc that doesn't work so I can see what went wrong.
I've had this problem when i was trying to setup via lua and ended up using vimscript. Just now i tried again and moved the call to coq before the lsp servers setup and it worked fine.
This was the key to reproducing the issue for me. Will post a minimal config soon.
The config that doesn't work looks like so:
lua << EOF
local lsp = require("lspconfig")
local coq = require("coq")
vim.g.coq_settings = {
auto_start = true
}
EOF
However, this works:
lua << EOF
vim.g.coq_settings = {
auto_start = true
}
local lsp = require("lspconfig")
local coq = require("coq")
EOF
@ms-jpq Tried to minimize it as much as I could, here's a working version I was able to use to reproduce the issue.
COQ complains about snippets in case 1 (but still works). case 2 doesn't start up automatically.
Seems the key to getting it working is setting vim.g.coq_settings
before the call to require("coq")
let g:python_host_program = '/usr/bin/python2.7'
let g:python3_host_prog = "/usr/local/opt/[email protected]/bin/python3"
" Plugin
call plug#begin('~/.local/share/nvim/plugged')
Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
call plug#end()
lua << EOF
-- CASE 1: If vim settings are enabled here, coq loads
vim.g.coq_settings = {
auto_start = true,
}
local coq = require "coq"
-- -- CASE 2: Placing the setting here doesn't start coq
-- vim.g.coq_settings = {
-- auto_start = true,
-- }
EOF
Setting vim.g.coq_settings
before require("coq")
solved the issue forr me too.
As a workaround, I've included an
autocmd
to start COQ as soon as Vim does, for the time being until this gets patched.augroup COQ autocmd! autocmd VimEnter * COQnow -s augroup END
I've had this problem when i was trying to setup via lua and ended up using vimscript. Just now i tried again and moved the call to coq before the lsp servers setup and it worked fine.
but, for example if i change it to
require('rmc.lsp') require('rmc.coq')
it won't startup anymore
Requiring coq before the lsp seems to work fine. Thanks
for those who use lazy.nvim, it looks like you should place vim.g.coq_settings...
just before require('lazy').setup..
for those who use lazy.nvim, it looks like you should place
vim.g.coq_settings...
just beforerequire('lazy').setup..
yes, i think so.
for those who use lazy.nvim, it looks like you should place
vim.g.coq_settings...
just beforerequire('lazy').setup..
Yep! This worked for me!
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.g.coq_settings = {
auto_start = true,
}
require("lazy").setup()