From 7f9cdd2b119eb47b3de7e8f4bc9c25c435a7a53e Mon Sep 17 00:00:00 2001 From: MasterGordon Date: Mon, 27 Sep 2021 22:14:28 +0200 Subject: [PATCH] added coq + fixed diagnostics --- lua/plugins.lua | 54 +++++++++++++++-------------- lua/plugins/coq.lua | 82 +++++++++++++++++++++++++++++++++++++++++++++ lua/plugins/lsp.lua | 8 ++--- 3 files changed, 114 insertions(+), 30 deletions(-) create mode 100644 lua/plugins/coq.lua diff --git a/lua/plugins.lua b/lua/plugins.lua index b89a609..60c4a13 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -64,7 +64,7 @@ return require("packer").startup( use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate", - after = "nvim-compe", + -- after = "nvim-compe", config = function() local npairs = require("nvim-autopairs") npairs.setup( @@ -74,13 +74,6 @@ return require("packer").startup( } ) - require("nvim-autopairs.completion.compe").setup( - { - map_cr = true, -- map 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 { context_commentstring = { enable = true, @@ -125,12 +118,12 @@ return require("packer").startup( "jose-elias-alvarez/null-ls.nvim" } } - use { + --[[ use { "hrsh7th/nvim-compe", config = function() require "plugins/compe" end - } + } ]] use { "nvim-telescope/telescope.nvim", config = function() @@ -199,23 +192,22 @@ return require("packer").startup( } use "jbyuki/venn.nvim" use "editorconfig/editorconfig-vim" - use( - { - "jameshiew/nvim-magic", - config = function() - require("nvim-magic").setup( - { - use_default_keymap = false - } - ) - end, - tag = "v0.2.1", -- recommended to pin to a tag and update manually as there may be breaking changes - requires = { - "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim" - } + use { + "jameshiew/nvim-magic", + config = function() + require("nvim-magic").setup( + { + use_default_keymap = false + } + ) + end, + tag = "v0.2.1", -- recommended to pin to a tag and update manually as there may be breaking changes + requires = { + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim" } - ) + } + use { "mfussenegger/nvim-jdtls", config = function() @@ -230,5 +222,15 @@ return require("packer").startup( end, 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': ''} }") + end + } end ) diff --git a/lua/plugins/coq.lua b/lua/plugins/coq.lua new file mode 100644 index 0000000..6e6a6d8 --- /dev/null +++ b/lua/plugins/coq.lua @@ -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 = ""}, + 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", "", [[pumvisible() ? "" : ""]], {expr = true, noremap = true}) +remap("i", "", [[pumvisible() ? "" : ""]], {expr = true, noremap = true}) +remap("i", "", [[pumvisible() ? "" : ""]], {expr = true, noremap = true}) +remap("i", "", [[pumvisible() ? "" : ""]], {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("") + else + return npairs.esc("") .. npairs.autopairs_cr() + end + else + return npairs.autopairs_cr() + end +end +remap("i", "", "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("") .. npairs.autopairs_bs() + else + return npairs.autopairs_bs() + end +end +remap("i", "", "v:lua.MUtils.BS()", {expr = true, noremap = true}) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 720748f..41f9250 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -8,19 +8,19 @@ vim.lsp.handlers["textDocument/documentSymbol"] = require "lsputil.symbols".docu vim.lsp.handlers["workspace/symbol"] = require "lsputil.symbols".workspace_handler vim.fn.sign_define( - "LspDiagnosticsSignError", + "DiagnosticSignError", {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"} ) vim.fn.sign_define( - "LspDiagnosticsSignWarning", + "DiagnosticSignWarning", {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"} ) vim.fn.sign_define( - "LspDiagnosticsSignHint", + "DiagnosticSignHint", {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"} ) vim.fn.sign_define( - "LspDiagnosticsSignInformation", + "DiagnosticSignInformation", {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"} )