diff --git a/coc-settings.json b/coc-settings.json index af9f164..3fc46bc 100644 --- a/coc-settings.json +++ b/coc-settings.json @@ -17,26 +17,49 @@ "coc-tsserver", "coc-lua", "coc-sh", - "coc-go" + "coc-go", + "coc-prettier", + "coc-eslint", + "coc-markdownlint", + "coc-vimlsp" ], "pyright.enable": true, "python.analysis.autoImportCompletions": true, "python.analysis.autoSearchPaths": true, "python.analysis.diagnosticMode": "workspace", + "rust-analyzer.enable": true, + "rust-analyzer.cargo.loadOutDirsFromCheck": true, + "rust-analyzer.procMacro.enable": true, + "clangd.enabled": true, + "clangd.fallbackFlags": ["-std=c++17"], + "html.enable": true, + "css.enable": true, + "typescript.enable": true, + "javascript.enable": true, + "eslint.enable": true, + "prettier.enable": true, "languageserver": { "zig": { "command": "zls", "filetypes": ["zig"], - "rootPatterns": ["build.zig"] + "rootPatterns": ["build.zig", "build.zig.zon"], + "settings": { + "zls": { + "enable_snippets": true, + "enable_ast_check_diagnostics": true, + "enable_build_on_save": true, + "build_on_save_step": "check" + } + } }, "nim": { "command": "nimlangserver", "filetypes": ["nim"], "rootPatterns": ["*.nimble", "*.nim"], - "trace.server": "verbose", "settings": { "nim": { - "nimsuggestPath": "${pkgs.nim}/bin/nimsuggest" + "nimsuggestPath": "nimsuggest", + "timeout": 120000 } } }, @@ -44,6 +67,27 @@ "command": "vls", "filetypes": ["v"], "rootPatterns": ["v.mod"] + }, + "lua": { + "command": "lua-language-server", + "filetypes": ["lua"], + "rootPatterns": [".luarc.json", ".luacheckrc", ".stylua.toml", "stylua.toml", "selene.toml"], + "settings": { + "Lua": { + "runtime": { + "version": "LuaJIT" + }, + "diagnostics": { + "globals": ["vim"] + }, + "workspace": { + "library": { + "${3rd}/luv/library": true, + "${3rd}/busted/library": true + } + } + } + } } } } diff --git a/lua/coc.lua b/lua/coc.lua index e69de29..eeb6d2f 100644 --- a/lua/coc.lua +++ b/lua/coc.lua @@ -0,0 +1,44 @@ +-- CoC configuration +vim.g.coc_global_extensions = { + 'coc-json', + 'coc-html', + 'coc-css', + 'coc-python', + 'coc-clangd', + 'coc-rust-analyzer', + 'coc-yaml', + 'coc-tsserver', + 'coc-lua', + 'coc-sh', + 'coc-go', + 'coc-prettier', + 'coc-eslint', + 'coc-markdownlint', + 'coc-vimlsp' +} + +-- Use and to navigate completion list +vim.keymap.set('i', '', function() + if vim.fn['coc#pum#visible']() == 1 then + return vim.fn['coc#pum#next'](1) + else + return '' + end +end, { expr = true, silent = true }) + +vim.keymap.set('i', '', function() + if vim.fn['coc#pum#visible']() == 1 then + return vim.fn['coc#pum#prev'](1) + else + return '' + end +end, { expr = true, silent = true }) + +-- Use to confirm completion +vim.keymap.set('i', '', function() + if vim.fn['coc#pum#visible']() == 1 then + return vim.fn['coc#pum#confirm']() + else + return '' + end +end, { expr = true, silent = true }) \ No newline at end of file diff --git a/lua/utils/t3_functions.lua b/lua/utils/t3_functions.lua index dc303fb..b462a6b 100644 --- a/lua/utils/t3_functions.lua +++ b/lua/utils/t3_functions.lua @@ -187,10 +187,11 @@ vim.api.nvim_create_user_command("Vsplit", function() end, {}) function _G.ShowDocumentation() - if vim.fn.CocAction("hasProvider", "hover") then - vim.fn.CocActionAsync("doHover") + local filetype = vim.bo.filetype + if filetype == "vim" or filetype == "help" then + vim.cmd("h " .. vim.fn.expand("")) else - vim.cmd("h " .. vim.bo.filetype) + vim.fn.CocActionAsync("doHover") end end