-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(lsp): Add basic coc support * fix(coc-nvim): Disable more plugins * feat(coc-nvim): add heirline integration and improve lazy loading * feat(coc-nvim): start adding coc mappings * chore: remove AstroLSP * docs(coc-nvim): add README * feat(coc-nvim): add json for coc configuration (#789) * feat(coc-nvim): add json for coc configuration * refactor(coc-nvim): configure `coc_global_extensions` in AstroCore --------- Co-authored-by: Micah Halter <micah@mehalter.com> * feat(coc-nvim): add v-mode selection format (#787) * feat(coc-nvim): add marketplace (#788) * fix(coc-nvim): force statusline redraw * chore(coc-nvim): normalize command calls * feat(coc-nvim): add service to statusbar Co-authored-by: William Roy <wroy@proton.me> * feat(coc-nvim): add extension for telescope.nvim (#792) Co-authored-by: Micah Halter <micah@mehalter.com> * fix(coc-nvim): default `cmdheight=1` when using coc-nvim * fix(coc-nvim): disable `foldcolumn` for coc lists * chore(coc-nvim): clean up heirline callbacks * feat(coc-nvim): add more missing LSP mappings * chore(coc-nvim): clean up package disabling to only core plugins --------- Co-authored-by: Uzair Aftab <uzaaft@outlook.com> Co-authored-by: William Roy <wroy@proton.me>
- Loading branch information
1 parent
04fb679
commit a911fef
Showing
4 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Conqueror of Completion | ||
|
||
Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers. | ||
|
||
**Repository:** <https://github.com/neoclide/coc.nvim> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
return { | ||
{ | ||
"neoclide/coc.nvim", | ||
branch = "release", | ||
cmd = { | ||
"CocCommand", | ||
"CocConfig", | ||
"CocDiagnostics", | ||
"CocDisable", | ||
"CocEnable", | ||
"CocInfo", | ||
"CocInstall", | ||
"CocList", | ||
"CocLocalConfig", | ||
"CocOpenLog", | ||
"CocOutline", | ||
"CocPrintErrors", | ||
"CocRestart", | ||
"CocSearch", | ||
"CocStart", | ||
"CocUninstall", | ||
"CocUpdate", | ||
"CocUpdateSync", | ||
"CocWatch", | ||
}, | ||
event = { "User AstroFile", "InsertEnter" }, | ||
dependencies = { | ||
"AstroNvim/astrocore", | ||
---@param opts AstroCoreOpts | ||
opts = function(_, opts) | ||
if not opts.options then opts.options = {} end | ||
if not opts.options.g then opts.options.g = {} end | ||
if not opts.options.opt then opts.options.opt = {} end | ||
opts.options.opt.cmdheight = 1 | ||
opts.options.g.coc_global_extensions = { | ||
"coc-json", | ||
"coc-marketplace", | ||
} | ||
|
||
if not opts.autocmds then opts.autocmds = {} end | ||
opts.autocmds.coc_settings = { | ||
{ | ||
event = "FileType", | ||
pattern = "list", | ||
desc = "disable foldcolumn for coc lists", | ||
callback = function() vim.wo.foldcolumn = "0" end, | ||
}, | ||
} | ||
|
||
if not opts.commands then opts.commands = {} end | ||
opts.commands.Format = { function() vim.fn.CocAction "format" end, desc = "Format file with LSP" } | ||
if not opts.mappings then opts.mappings = require("astrocore").empty_map_table() end | ||
local maps = assert(opts.mappings) | ||
maps.n["[d"] = { "<Plug>(coc-diagnostic-prev)", desc = "Previous diagnostic" } | ||
maps.n["]d"] = { "<Plug>(coc-diagnostic-next)", desc = "Next diagnostic" } | ||
maps.n["gD"] = { "<Plug>(coc-declaration)", desc = "Show the declaration of current symbol" } | ||
maps.n["gI"] = { "<Plug>(coc-implementation)", desc = "Show the implementation of current symbol" } | ||
maps.n["gT"] = { "<Plug>(coc-type-definition)", desc = "Show the definition of current type" } | ||
maps.n["gd"] = { "<Plug>(coc-definition)", desc = "Show the definition of current symbol" } | ||
maps.n["gr"] = { "<Plug>(coc-references)", desc = "Show the references of current symbol" } | ||
maps.n["<Leader>lR"] = maps.n.gr | ||
maps.n["<Leader>la"] = { "<Plug>(coc-codeaction-cursor)", desc = "LSP code action" } | ||
maps.n["<Leader>lc"] = { "<Cmd>CocConfig<CR>", desc = "Configuration" } | ||
maps.n["<Leader>lf"] = { function() vim.cmd.Format() end, desc = "Format buffer" } | ||
maps.n["<Leader>lm"] = { "<Cmd>CocList marketplace<CR>", desc = "Marketplace" } | ||
maps.n["<Leader>lr"] = { "<Plug>(coc-rename)", desc = "Rename current symbol" } | ||
maps.n["<Leader>ls"] = { "<Cmd>CocList symbols<CR>", desc = "Search symbols" } | ||
maps.n["<Leader>lS"] = { "<Cmd>CocOutline<CR>", desc = "Symbols outline" } | ||
maps.n["<Leader>lL"] = { "<Plug>(coc-codelens-action)", desc = "LSP CodeLens run" } | ||
maps.n["<Leader>uL"] = { "<Cmd>CocCommand document.toggleCodeLens<CR>", desc = "Toggle CodeLens" } | ||
maps.n["<Leader>uh"] = { "<Cmd>CocCommand document.toggleInlayHint<CR>", desc = "Toggle LSP inlay hints" } | ||
maps.x["<Leader>lF"] = { "<Plug>(coc-format-selected)", desc = "Format selection" } | ||
maps.n["K"] = { | ||
function() | ||
local cw = vim.fn.expand "<cword>" | ||
if vim.fn.index({ "vim", "help" }, vim.bo.filetype) >= 0 then | ||
vim.api.nvim_command("h " .. cw) | ||
elseif vim.api.nvim_eval "coc#rpc#ready()" then | ||
vim.fn.CocActionAsync "doHover" | ||
else | ||
vim.api.nvim_command("!" .. vim.o.keywordprg .. " " .. cw) | ||
end | ||
end, | ||
desc = "Hover symbol details", | ||
} | ||
end, | ||
}, | ||
}, | ||
{ | ||
"rebelot/heirline.nvim", | ||
opts = function(_, opts) | ||
local statusline, status = opts.statusline, require "astroui.status" | ||
local function coc_diagnostic(coc_type, diagnostic_type) | ||
return { | ||
provider = function(self) | ||
local count = vim.b[self.bufnr or 0].coc_diagnostic_info[coc_type] | ||
return status.utils.stylize( | ||
count ~= 0 and tostring(count) or "", | ||
{ icon = { kind = "Diagnostic" .. diagnostic_type, padding = { left = 1, right = 1 } } } | ||
) | ||
end, | ||
hl = { fg = "diag_" .. diagnostic_type:upper() }, | ||
} | ||
end | ||
statusline[5] = status.component.builder { -- diagnostics | ||
coc_diagnostic("error", "Error"), | ||
coc_diagnostic("warning", "Warn"), | ||
coc_diagnostic("information", "Info"), | ||
coc_diagnostic("hint", "Hint"), | ||
update = { "User", pattern = "CocDiagnosticChange" }, | ||
init = status.init.update_events { "BufEnter" }, | ||
surround = { | ||
separator = "right", | ||
condition = function() | ||
for _, count in pairs(vim.b.coc_diagnostic_info or {}) do | ||
if type(count) == "number" and count > 0 then return true end | ||
end | ||
return false | ||
end, | ||
}, | ||
on_click = { name = "coc_diagnostic", callback = function() vim.schedule(vim.cmd.CocDiagnostic) end }, | ||
} | ||
statusline[9] = status.component.builder { -- status | ||
{ | ||
provider = function() return vim.g.coc_status end, | ||
on_click = { name = "coc_status", callback = function() vim.schedule(vim.cmd.CocInfo) end }, | ||
}, | ||
{ | ||
provider = function() | ||
if vim.g.coc_status then | ||
return status.utils.stylize(" ", { icon = { kind = "ActiveLSP", padding = { left = 1 } } }) | ||
end | ||
end, | ||
on_click = { | ||
name = "coc_services", | ||
callback = vim.schedule_wrap(function() vim.cmd.CocList "services" end), | ||
}, | ||
}, | ||
update = { | ||
"User", | ||
pattern = "CocStatusChange", | ||
callback = function() vim.schedule(vim.cmd.redrawstatus) end, | ||
}, | ||
surround = { separator = "right", condition = function() return vim.g.coc_status ~= nil end }, | ||
} | ||
end, | ||
}, | ||
-- disable core lsp plugins | ||
{ "AstroNvim/astrolsp", enabled = false }, | ||
{ "folke/neoconf.nvim", enabled = false }, | ||
{ "folke/neodev.nvim", enabled = false }, | ||
{ "jay-babu/mason-null-ls.nvim", enabled = false }, | ||
{ "neovim/nvim-lspconfig", enabled = false }, | ||
{ "nvimtools/none-ls.nvim", enabled = false }, | ||
{ "stevearc/aerial.nvim", enabled = false }, | ||
{ "williamboman/mason-lspconfig.nvim", enabled = false }, | ||
-- cmp | ||
{ "hrsh7th/cmp-buffer", enabled = false }, | ||
{ "hrsh7th/cmp-nvim-lsp", enabled = false }, | ||
{ "hrsh7th/cmp-path", enabled = false }, | ||
{ "hrsh7th/nvim-cmp", enabled = false }, | ||
{ "rcarriga/cmp-dap", enabled = false }, | ||
{ "saadparwaiz1/cmp_luasnip", enabled = false }, | ||
-- luaship | ||
{ "L3MON4D3/LuaSnip", enabled = false }, | ||
{ "rafamadriz/friendly-snippets", enabled = false }, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# telescope-coc.nvim | ||
|
||
An extension for telescope.nvim that allows you to find/filter/preview/pick results from coc.nvim. | ||
|
||
**Repository:** <https://github.com/fannheyward/telescope-coc.nvim> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
return { | ||
"nvim-telescope/telescope.nvim", | ||
dependencies = { "fannheyward/telescope-coc.nvim" }, | ||
opts = function(_, opts) | ||
require("telescope").load_extension "coc" | ||
if not opts.extensions then opts.extensions = {} end | ||
opts.extensions.coc = { | ||
theme = "ivy", | ||
prefer_locations = true, -- always use Telescope locations to preview definitions/declarations/implementations etc | ||
} | ||
end, | ||
} |