DEV Community

Cover image for Neovim LSP to replace VSCode

Neovim LSP to replace VSCode

Cason Adams on December 26, 2021

If you are looking for a much simpler solution to replacing VSCode with a terminal editor I suggest reading my minimal vim post. TLDR; ...
Collapse
 
voyeg3r profile image
Sérgio Araújo

It would be great adding a safe call at each plugin setting like this:

local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
    return
end
Enter fullscreen mode Exit fullscreen mode

Just in case the call fail, we just get a return without trying to read the rest of config file, the same for the packer config:

-- Use a protected call so we don't error out on first use
local status_ok, packer = pcall(require, "packer")
if not status_ok then
    return
end
Enter fullscreen mode Exit fullscreen mode
Collapse
 
voyeg3r profile image
Sérgio Araújo

By the way pcall it is, if I am not wrong, the same as a try catch statement.

Collapse
 
casonadams profile image
Cason Adams

Great suggestion. I updated the git repo. Not sure if I should update this post or not. I am thinking no. And hopefully most people just go look at the source repo.

Thread Thread
 
kchawla_pi profile image
Kshitij Chawla

I always add an update to my posts. A lot of new devs rely on good blogs to get started.

Collapse
 
chanid profile image
ChaniD

Why?

Collapse
 
casonadams profile image
Cason Adams

Why replace vscode?

I work in a terminal.

Collapse
 
sumanthlingappa profile image
Sumanth Lingappa

@casonadams
Great article.

However, I find it difficult to understand, vscode has Remote-SSH extension and you can connect vscode to your server.

My personal experience has been 'its difficult to maintain huge nvim/vim configs over a period of time'. And instead of focusing on my actual work, I end up in configure-reconfigure vim/nvim configs most of the time.

Since I am very comfortable with vim, I use vscode-vim all the time.

Thread Thread
 
casonadams profile image
Cason Adams

Thanks! It's not that vscode is bad and yes there are some other amazing features like the remote connect offering, and live share.

For me I use nvim as my daily driver because I work in a terminal all day. And I find it fun to tweak things here and there as needed.

I do follow your word of caution that one can go down a hole of wasted time with config tweaking. And the whole point of learning vim, is that's it's installed on more servers. So if you need to hop on a machine and check it out you can. But that defeats the purpose of this article, because once you configure vim this way, it's not vanilla any more.

Thanks for your comment.

Thread Thread
 
sumanthlingappa profile image
Sumanth Lingappa

Agreed.

I am a big fan of vim/nvim and I am using vim for 10 years.

Recently, when I looked back, I was (wasting) a lot of my time in trying out new configs just for the fun of it.

And decided to stick to vscode as the main editor, ofcourse with vscode-vim extension :-)

Thread Thread
 
casonadams profile image
Cason Adams

So I tinkered with vscode for a bit, and there is just as much config with it as there is vim. With less flexibility. Going to stick with vim. Thanks for the thoughts though.

Thread Thread
 
sumanthlingappa profile image
Sumanth Lingappa

@casonadams I would love to see your work in your vim config.

Have you made any videos?

Collapse
 
abdoulayegk profile image
Abdoulaye Balde

I also have a very simple and nice configuration check it out here.
github.com/abdoulayegk/dotefiles
Here is how it looks.
To install it just follow the instructions given in the above link or just download it and put the init.vim file inside the is file ~/.config/nvim then open nvim it will install everything for you.
Enjoy 😊🤩

Collapse
 
casonadams profile image
Cason Adams

Looks like you are using coc and viml. I have a similar (much simpler) example in this post

This post is very specific to getting up and running with neovim and the built-in LSP. Including some nice to haves to walk away from VSCode, and live in a terminal editor.

Collapse
 
margotpaon profile image
Margot Paon Garcia

Hello everyone!
@casonadams in _lsp.lua on line 93

We have this

capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()),

Today we need swap to

capabilities = require("cmp_nvim_lsp").dafault_capabilities(vim.lsp.protocol.make_client_capabilities()),

Because update_capabilities is now deprecated

That is it and thank you for great article!

Collapse
 
juanfrank77 profile image
Juan F Gonzalez

Yessss. Let's go Vim!

Collapse
 
eggbean profile image
eggbean

It'll probably take hours for me to translate my vimscript configuration to lua, so I want to hear if there would be any advantages in doing so.

Collapse
 
casonadams profile image
Cason Adams

Haha, yeah this post is my hours of converting my viml to lua. I'm not sure on the bang for the buck yet.

But using lua moving forward might open more doors.

I think if one were wanting to start using the built-in lsp stuff it will be worth the effort.

Collapse
 
danielratmiroff profile image
Daniel

Speed. Lua is faster than vimscript