Add coc basic config, not fully working yet
This commit is contained in:
134
nvim-coc/lua/plugins/lsp/coc.lua
Executable file
134
nvim-coc/lua/plugins/lsp/coc.lua
Executable file
@@ -0,0 +1,134 @@
|
||||
return {
|
||||
"neoclide/coc.nvim",
|
||||
branch = "release",
|
||||
config = function()
|
||||
-- Completion support and diagnostics
|
||||
vim.cmd("set completeopt=menuone,noinsert,noselect")
|
||||
|
||||
-- Diagnostics settings
|
||||
vim.cmd("set updatetime=300")
|
||||
vim.cmd('autocmd CursorHold * silent! CocAction("diagnosticRefresh")')
|
||||
|
||||
-- Snippet support
|
||||
vim.g.coc_user_snippets = vim.fn.expand("~/.config/nvim/snippets")
|
||||
|
||||
-- Signature help (popup)
|
||||
vim.cmd('autocmd CursorHold,CursorHoldI * silent! CocAction("showSignatureHelp")')
|
||||
|
||||
-- Enable some coc extensions
|
||||
vim.g.coc_global_extensions = {
|
||||
"coc-snippets", -- Snippets support
|
||||
"coc-pyright", -- Python LSP
|
||||
"coc-tsserver", -- JavaScript/TypeScript LSP
|
||||
"coc-json", -- JSON LSP
|
||||
"coc-html", -- HTML LSP
|
||||
"coc-css", -- CSS LSP
|
||||
"coc-lua", -- Lua LSP
|
||||
"coc-diagnostic", -- Diagnostics
|
||||
"coc-syntax", -- Syntax highlighting
|
||||
"coc-eslint", -- ESLint (null-ls replacement for JS/TS)
|
||||
"coc-prettier", -- Prettier formatting
|
||||
"coc-java",
|
||||
}
|
||||
|
||||
--------------
|
||||
-- KEYBINDS --
|
||||
--------------
|
||||
local keymap = vim.keymap
|
||||
local opts = { noremap = true, silent = true, desc = "" }
|
||||
vim.opt.signcolumn = 'yes'
|
||||
|
||||
-- LSP actions
|
||||
opts.desc = "Jump to previous diagnostics"
|
||||
keymap.set("n", "[d", "<Plug>(coc-diagnostic-prev)", opts)
|
||||
|
||||
opts.desc = "Jump to next diagnostics"
|
||||
keymap.set("n", "]d", "<Plug>(coc-diagnostic-next)", opts)
|
||||
|
||||
opts.desc = "Show LSP references"
|
||||
keymap.set("n", "gR", "<cmd>CocAction('editor.action.showReferences')<CR>", opts)
|
||||
|
||||
opts.desc = "Go to declaration"
|
||||
keymap.set("n", "gD", ":CocCommand editor.action.goToDeclaration<CR>", opts)
|
||||
|
||||
opts.desc = "Show LSP definitions"
|
||||
keymap.set("n", "gd", "<cmd>CocAction('editor.action.goToDefinition')<CR>", opts)
|
||||
|
||||
opts.desc = "Show LSP implementations"
|
||||
keymap.set("n", "gi", "<cmd>CocAction('editor.action.goToImplementation')<CR>", opts)
|
||||
|
||||
opts.desc = "Show LSP type definitions"
|
||||
keymap.set("n", "gt", "<cmd>CocAction('editor.action.goToTypeDefinition')<CR>", opts)
|
||||
|
||||
opts.desc = "See available code actions"
|
||||
keymap.set({ "n", "v" }, "<leader>ca", "<cmd>CocAction('editor.action.quickFix')<CR>", opts)
|
||||
|
||||
opts.desc = "Format current file"
|
||||
keymap.set("n", "<leader>gf", "<cmd>CocCommand editor.action.formatDocument<CR>", opts)
|
||||
|
||||
opts.desc = "Smart rename"
|
||||
keymap.set("n", "<leader>n", "<cmd>CocCommand editor.action.rename<CR>", opts)
|
||||
|
||||
opts.desc = "Show buffer diagnostics"
|
||||
keymap.set("n", "ga", "<cmd>CocList diagnostics<CR>", opts)
|
||||
|
||||
opts.desc = "Show line diagnostics"
|
||||
keymap.set("n", "gA", "<cmd>CocAction('diagnostic.showLineDiagnostics')<CR>", opts)
|
||||
|
||||
opts.desc = "Go to previous diagnostic"
|
||||
keymap.set("n", "[d", "<cmd>CocAction('diagnostic.gotoPrev')<CR>", opts)
|
||||
|
||||
opts.desc = "Go to next diagnostic"
|
||||
keymap.set("n", "]d", "<cmd>CocAction('diagnostic.gotoNext')<CR>", opts)
|
||||
|
||||
opts.desc = "Show documentation for what is under cursor"
|
||||
keymap.set("n", "<leader>k", "<cmd>CocAction('editor.action.showHover')<CR>", opts)
|
||||
|
||||
opts.desc = "Restart LSP"
|
||||
keymap.set("n", "<leader>rs", "<cmd>CocRestart<CR>", opts)
|
||||
|
||||
-- CMP replacement
|
||||
|
||||
-- Mapping for next suggestion
|
||||
opts.desc = "Next suggestion"
|
||||
vim.keymap.set("i", "<C-j>", "<Cmd>coc#select_next()<CR>", opts)
|
||||
|
||||
-- Mapping for previous suggestion
|
||||
opts.desc = "Previous suggestion"
|
||||
vim.keymap.set("i", "<C-k>", "<Cmd>coc#select_prev()<CR>", opts)
|
||||
|
||||
-- Mapping for scrolling documentation forward
|
||||
opts.desc = "Scroll docs forward"
|
||||
vim.keymap.set("i", "<C-S-j>", "<Cmd>CocScrollFloat -4<CR>", opts)
|
||||
|
||||
-- Mapping for scrolling documentation backward
|
||||
opts.desc = "Scroll docs back"
|
||||
vim.keymap.set("i", "<C-S-k>", "<Cmd>CocScrollFloat 4<CR>", opts)
|
||||
|
||||
-- Mapping to show completion suggestions
|
||||
opts.desc = "Show completion suggestions"
|
||||
vim.keymap.set("i", "<C-Space>", "<C-r>=coc#refresh()<CR>", opts)
|
||||
|
||||
-- Mapping for Tab key (with snippet expansion and fallback)
|
||||
opts.desc = "Complete or expand snippet"
|
||||
keymap.set('i', '<TAB>', 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "<TAB>" : coc#refresh()', opts)
|
||||
|
||||
-- Mapping for jumping to the next placeholder in snippets
|
||||
opts.desc = "Jump to next placeholder in snippet"
|
||||
vim.keymap.set("i", "<C-p>", function()
|
||||
if vim.fn["coc#snippets#jumpable"]() == 1 then
|
||||
vim.fnkeys(vim.api.nvim_replace_termcodes("<Tab>", true, true, true), "n")
|
||||
end
|
||||
end, opts)
|
||||
|
||||
-- Mapping for jumping to the previous placeholder in snippets
|
||||
opts.desc = "Jump to previous placeholder in snippet"
|
||||
vim.keymap.set("i", "<C-S-p>", function()
|
||||
if vim.fn["coc#snippets#jumpable"]() == 1 then
|
||||
vim.fn["coc#snippets#jump"](-1)
|
||||
else
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-P>", true, true, true), "n")
|
||||
end
|
||||
end, opts)
|
||||
end,
|
||||
}
|
14
nvim-coc/lua/plugins/lsp/fidget.lua
Executable file
14
nvim-coc/lua/plugins/lsp/fidget.lua
Executable file
@@ -0,0 +1,14 @@
|
||||
return {
|
||||
-- notifications && lsp progress msgs
|
||||
"j-hui/fidget.nvim",
|
||||
config = function()
|
||||
require("fidget").setup({
|
||||
notification = {
|
||||
window = {
|
||||
winblend = 0,
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
}
|
29
nvim-coc/lua/plugins/lsp/treesitter.lua
Executable file
29
nvim-coc/lua/plugins/lsp/treesitter.lua
Executable file
@@ -0,0 +1,29 @@
|
||||
return {
|
||||
-- syntax highlighting
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"cpp",
|
||||
"hyprlang",
|
||||
"java",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"python",
|
||||
"rust",
|
||||
"typescript",
|
||||
"verilog"
|
||||
},
|
||||
sync_install = false,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
disable = { "tex" }
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
Reference in New Issue
Block a user