added coq + fixed diagnostics

This commit is contained in:
MasterGordon 2021-09-27 22:14:28 +02:00
parent fc6344e1ff
commit 7f9cdd2b11
3 changed files with 114 additions and 30 deletions

View File

@ -64,7 +64,7 @@ return require("packer").startup(
use { use {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
run = ":TSUpdate", run = ":TSUpdate",
after = "nvim-compe", -- after = "nvim-compe",
config = function() config = function()
local npairs = require("nvim-autopairs") local npairs = require("nvim-autopairs")
npairs.setup( npairs.setup(
@ -74,13 +74,6 @@ return require("packer").startup(
} }
) )
require("nvim-autopairs.completion.compe").setup(
{
map_cr = true, -- map <CR> on insert mode
map_complete = true, -- it will auto insert `(` after select function or method item
auto_select = false -- auto select first item
}
)
require "nvim-treesitter.configs".setup { require "nvim-treesitter.configs".setup {
context_commentstring = { context_commentstring = {
enable = true, enable = true,
@ -125,12 +118,12 @@ return require("packer").startup(
"jose-elias-alvarez/null-ls.nvim" "jose-elias-alvarez/null-ls.nvim"
} }
} }
use { --[[ use {
"hrsh7th/nvim-compe", "hrsh7th/nvim-compe",
config = function() config = function()
require "plugins/compe" require "plugins/compe"
end end
} } ]]
use { use {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
config = function() config = function()
@ -199,23 +192,22 @@ return require("packer").startup(
} }
use "jbyuki/venn.nvim" use "jbyuki/venn.nvim"
use "editorconfig/editorconfig-vim" use "editorconfig/editorconfig-vim"
use( use {
{ "jameshiew/nvim-magic",
"jameshiew/nvim-magic", config = function()
config = function() require("nvim-magic").setup(
require("nvim-magic").setup( {
{ use_default_keymap = false
use_default_keymap = false }
} )
) end,
end, tag = "v0.2.1", -- recommended to pin to a tag and update manually as there may be breaking changes
tag = "v0.2.1", -- recommended to pin to a tag and update manually as there may be breaking changes requires = {
requires = { "nvim-lua/plenary.nvim",
"nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim"
"MunifTanjim/nui.nvim"
}
} }
) }
use { use {
"mfussenegger/nvim-jdtls", "mfussenegger/nvim-jdtls",
config = function() config = function()
@ -230,5 +222,15 @@ return require("packer").startup(
end, end,
requires = {"mfussenegger/nvim-dap"} requires = {"mfussenegger/nvim-dap"}
} }
use {
"ms-jpq/coq_nvim",
branch = "coq",
config = function()
require "plugins/coq"
end,
setup = function()
vim.cmd("let g:coq_settings = { 'auto_start': v:true, 'keymaps': {'manual_completion': '<c-f>'} }")
end
}
end end
) )

82
lua/plugins/coq.lua Normal file
View File

@ -0,0 +1,82 @@
local remap = vim.api.nvim_set_keymap
local npairs = require("nvim-autopairs")
npairs.setup({map_bs = false})
vim.g.coq_settings = {
keymap = {recommended = false, manual_complete = "<c-f>"},
display = {
preview = {
positions = {
east = 1,
north = 2,
south = 3,
west = 4
}
},
icons = {
mappings = {
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 = "",
Character = "",
Number = "",
Parameter = "",
String = ""
}
}
}
}
-- these mappings are coq recommended mappings unrelated to nvim-autopairs
remap("i", "<esc>", [[pumvisible() ? "<c-e><esc>" : "<esc>"]], {expr = true, noremap = true})
remap("i", "<c-c>", [[pumvisible() ? "<c-e><c-c>" : "<c-c>"]], {expr = true, noremap = true})
remap("i", "<tab>", [[pumvisible() ? "<c-n>" : "<tab>"]], {expr = true, noremap = true})
remap("i", "<s-tab>", [[pumvisible() ? "<c-p>" : "<bs>"]], {expr = true, noremap = true})
-- skip it, if you use another global object
_G.MUtils = {}
MUtils.CR = function()
if vim.fn.pumvisible() ~= 0 then
if vim.fn.complete_info({"selected"}).selected ~= -1 then
return npairs.esc("<c-y>")
else
return npairs.esc("<c-e>") .. npairs.autopairs_cr()
end
else
return npairs.autopairs_cr()
end
end
remap("i", "<cr>", "v:lua.MUtils.CR()", {expr = true, noremap = true})
MUtils.BS = function()
if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({"mode"}).mode == "eval" then
return npairs.esc("<c-e>") .. npairs.autopairs_bs()
else
return npairs.autopairs_bs()
end
end
remap("i", "<bs>", "v:lua.MUtils.BS()", {expr = true, noremap = true})

View File

@ -8,19 +8,19 @@ vim.lsp.handlers["textDocument/documentSymbol"] = require "lsputil.symbols".docu
vim.lsp.handlers["workspace/symbol"] = require "lsputil.symbols".workspace_handler vim.lsp.handlers["workspace/symbol"] = require "lsputil.symbols".workspace_handler
vim.fn.sign_define( vim.fn.sign_define(
"LspDiagnosticsSignError", "DiagnosticSignError",
{texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"} {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"}
) )
vim.fn.sign_define( vim.fn.sign_define(
"LspDiagnosticsSignWarning", "DiagnosticSignWarning",
{texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"} {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"}
) )
vim.fn.sign_define( vim.fn.sign_define(
"LspDiagnosticsSignHint", "DiagnosticSignHint",
{texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"} {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}
) )
vim.fn.sign_define( vim.fn.sign_define(
"LspDiagnosticsSignInformation", "DiagnosticSignInformation",
{texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"} {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}
) )