no coq for latex

This commit is contained in:
2022-11-08 20:32:39 -05:00
parent 5989e4213d
commit 914b98ff69
4 changed files with 492 additions and 439 deletions
+138 -101
View File
@@ -1,5 +1,5 @@
vim.g.coq_settings = {
auto_start = 'shut-up',
-- auto_start = 'shut-up',
keymap = {
eval_snips = "<Leader>se",
},
@@ -26,9 +26,9 @@ vim.g.coq_settings = {
local coq = require('coq')
require('coq_3p') {
{ src = 'vimtex', short_name = 'TEX'},
{ src = 'nvimlua', short_name = 'NLUA', conf_only = true},
{ src = 'bc', short_name = 'CALC', precision = 8},
{ src = 'vimtex', short_name = 'TEX' },
{ src = 'nvimlua', short_name = 'NLUA', conf_only = true },
{ src = 'bc', short_name = 'CALC', precision = 8 },
}
@@ -38,8 +38,8 @@ lspstatus.register_progress()
local function find_repo_root(names)
local util = require("lspconfig.util")
local config = names.configfiles
for _, i in ipairs(config) do
local gitroot = util.root_pattern('.git')(i)
local function matcher(filename, _bufnr)
local gitroot = util.root_pattern('.git')(filename)
if gitroot then
for _, file in ipairs(config) do
if util.path.is_file(util.path.join(gitroot, file)) then
@@ -47,49 +47,52 @@ local function find_repo_root(names)
end
end
end
return util.root_pattern(unpack(config))(filename)
end
return matcher
end
local lsp_confs = {
sumneko_lua = {
settings = {
Lua = {
-- Settings for working with nvim (copied from https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua)
runtime = {
version = 'LuaJIT',
path = runtime_path,
},
diagnostics = {
globals = {'vim'},
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
},
},
},
rust_analyzer = {
cmd_env = {
CARGO_TARGET_DIR = "/tmp/rust-analyzer"
},
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
allTargets = false,
},
sumneko_lua = {
settings = {
Lua = {
-- Settings for working with nvim (copied from https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua)
runtime = {
version = 'LuaJIT',
path = runtime_path,
},
diagnostics = {
globals = { 'vim' },
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
},
},
},
rust_analyzer = {
cmd_env = {
CARGO_TARGET_DIR = "/tmp/rust-analyzer"
},
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
allTargets = false,
},
cargo = {
features = "all",
}
},
},
},
ccls = {},
},
},
},
ccls = {},
jedi_language_server = {
filetypes = { "python", "sage.python" },
},
gopls = {},
gopls = {},
dartls = {},
tsserver = {
root_dir = find_repo_root({
@@ -100,17 +103,17 @@ local lsp_confs = {
root_dir = find_repo_root({
configfiles = { ".eslintrc", ".eslintrc.js", "package.json" }
}),
on_new_config = function (config, new_root_dir)
local default_config = require('lspconfig.server_configurations.eslint').default_config
default_config.on_new_config(config, new_root_dir)
on_new_config = function(config, new_root_dir)
local default_config = require('lspconfig.server_configurations.eslint').default_config
default_config.on_new_config(config, new_root_dir)
local util = require('lspconfig.util')
local pnp_cjs = util.path.join(new_root_dir, '.pnp.cjs')
local pnp_js = util.path.join(new_root_dir, '.pnp.js')
if util.path.exists(pnp_cjs) or util.path.exists(pnp_js) then
config.cmd = { 'yarn', 'exec', unpack(default_config.cmd) }
end
end
local util = require('lspconfig.util')
local pnp_cjs = util.path.join(new_root_dir, '.pnp.cjs')
local pnp_js = util.path.join(new_root_dir, '.pnp.js')
if util.path.exists(pnp_cjs) or util.path.exists(pnp_js) then
config.cmd = { 'yarn', 'exec', unpack(default_config.cmd) }
end
end
},
svelte = {},
svls = {},
@@ -120,89 +123,123 @@ local lsp_confs = {
local lsp_special_setup = {
}
local function on_attach(client, _bufnr)
lspstatus.on_attach(client)
end
local lspconfig = require('lspconfig')
for server, conf in pairs(lsp_confs) do
local source_on_attach = conf.on_attach
if source_on_attach == nil then
conf.on_attach = on_attach
else
conf.on_attach = function(client, bufnr)
on_attach(client, bufnr)
source_on_attach(client, bufnr)
end
end
local source_on_attach = conf.on_attach
if source_on_attach == nil then
conf.on_attach = on_attach
else
conf.on_attach = function(client, bufnr)
on_attach(client, bufnr)
source_on_attach(client, bufnr)
end
end
conf.capabilities = vim.tbl_deep_extend(
"keep",
conf.capabilities or {},
lspstatus.capabilities
)
conf.capabilities = vim.tbl_deep_extend(
"keep",
conf.capabilities or {},
lspstatus.capabilities
)
local final_config = coq.lsp_ensure_capabilities(conf)
local final_config = coq.lsp_ensure_capabilities(conf)
local special_setup = lsp_special_setup[server]
if special_setup then
special_setup(final_config)
else
lspconfig[server].setup(final_config)
end
local special_setup = lsp_special_setup[server]
if special_setup then
special_setup(final_config)
else
lspconfig[server].setup(final_config)
end
end
local null_ls = require('null-ls')
null_ls.setup({
sources = {
null_ls.builtins.diagnostics.chktex,
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.shellcheck,
sources = {
null_ls.builtins.diagnostics.chktex,
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.code_actions.gitsigns,
},
null_ls.builtins.code_actions.gitsigns,
},
})
vim.diagnostic.config({
severity_sort = true,
update_in_insert = true,
float = {
source = true,
},
severity_sort = true,
update_in_insert = true,
float = {
source = true,
},
})
do -- signs
local signs = {
{'DiagnosticSignError', text='×', texthl='DiagnosticSignError'},
{'DiagnosticSignWarn', text='>', texthl='DiagnosticSignWarn'},
{'DiagnosticSignInfo', text='I', texthl='DiagnosticSignInfo'},
{'DiagnosticSignHint', text='H', texthl='DiagnosticSignHint'},
}
for _, sign in pairs(signs) do
local name = sign[1]
local opts = sign
opts[1] = nil
vim.fn.sign_define(name, opts)
end
local signs = {
{ 'DiagnosticSignError', text = '×', texthl = 'DiagnosticSignError' },
{ 'DiagnosticSignWarn', text = '>', texthl = 'DiagnosticSignWarn' },
{ 'DiagnosticSignInfo', text = 'I', texthl = 'DiagnosticSignInfo' },
{ 'DiagnosticSignHint', text = 'H', texthl = 'DiagnosticSignHint' },
}
for _, sign in pairs(signs) do
local name = sign[1]
local opts = sign
opts[1] = nil
vim.fn.sign_define(name, opts)
end
end
local map = vim.api.nvim_set_keymap
map(
'n',
'K',
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? 'K' : '<Cmd>lua vim.lsp.buf.hover()<CR>']],
{noremap = true, expr = true}
'n',
'K',
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? 'K' : '<Cmd>lua vim.lsp.buf.hover()<CR>']],
{ noremap = true, expr = true }
)
map(
'n',
'<C-]>',
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? '<C-]>' : '<Cmd>lua vim.lsp.buf.definition()<CR>']],
{noremap = true, expr = true}
'n',
'<C-]>',
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? '<C-]>' : '<Cmd>lua vim.lsp.buf.definition()<CR>']],
{ noremap = true, expr = true }
)
local M = {}
M.format_on_save_hook = function()
local enabled = vim.b.format_on_save
if enabled == nil then
enabled = true
end
if enabled ~= 0 and enabled ~= false then
vim.lsp.buf.format({ async = false })
end
end
vim.cmd [[
augroup lspconfig
augroup hoverlspconfig
au!
" diagnostic on hover
au BufWritePre * lua require'lsp'.format_on_save_hook()
au CursorHold * lua vim.diagnostic.open_float({focus = false})
augroup END
]]
vim.api.nvim_create_autocmd('FileType', {
pattern = "*",
callback = function()
if vim.bo.filetype ~= "plaintex" and vim.bo.filetype ~= "tex" and vim.bo.filetype ~= "latex" then
vim.cmd [[ :COQnow -s ]]
end
end
})
-- vim.cmd [[
-- augroup disabletexlsp
-- autocmd!
-- autocmd FileType tex :COQstop
-- augroup END
-- ]]
return M