Setting Up Deno's LSP in Neovim
suresh pradhana
Configure Deno LSP in Neovim with coc.nvim and coc-deno Extension
Install coc.nvim
coc.nvim is a language server protocol client for neovim. It provides language support for various languages.
Install coc.nvim using your favorite plugin manager. I use lazy.nvim, in Lua,for
others
check this link
require('lazy') {
{'neoclide/coc.nvim', {'branch': 'release'}}
}
Install coc-deno extension
coc uses extensions to provide language support. Install the coc-deno extension using the following command:
:CocInstall coc-denoor add it to your init.lua file to load the extension on startup:
vim.g.coc_global_extensions = { 'coc-deno' }
you can add your required extensions to the coc_global_extensions list.
link to the deno extension: coc-deno and check other extensions here
Configuration
Just like vscode lsp configuration, you can configure the deno lsp in coc-settings.json file. You can open the file using :CocConfig command. Add the following configuration to the file:
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true,
"coc.preferences.formatOnSave": true,
"coc.preferences.enableMessageDialog": true,
"suggest.floatConfig": {
"border": true
},
"signature.floatConfig": {
"border": true
},
"hover.floatConfig": {
"border": true
},
"svelte.enable-ts-plugin": true,
"snippets.ultisnips.pythonPrompt": false
}deno.enable: Enable Deno LSPdeno.lint: Enable lintingdeno.unstable: Enable unstable featurescoc.preferences.formatOnSave: Format on save
the other are optional configurations for float windows and other plugins.
if
deno.enableis not set to true, you have to enable it manually using:CocCommand deno.initilizeWorkspacecommand.
Conclusion
This is how i set up deno lsp in neovim using coc.nvim and coc-deno extension. for more information check the official documentation of the plugins and extensions.