{"id":2087,"date":"2022-06-12T03:35:17","date_gmt":"2022-06-11T22:05:17","guid":{"rendered":"https:\/\/smarttech101.com\/?p=2087"},"modified":"2023-08-25T17:33:03","modified_gmt":"2023-08-25T12:03:03","slug":"nvim-lsp-configure-language-servers-shortcuts-highlights","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/","title":{"rendered":"Nvim lsp: configure language servers, shortcuts, highlights"},"content":{"rendered":"\n<p>Nvim LSP (Neovim Language Server Protocol) enables you to code efficiently by predicting what you are going to type, early diagnosis, etc. In this article, I will explain what is LSP, what are language servers, how to configure them in nvim, highlight symbols under the cursor, keybindings for code actions, rename, hover info, implementations, definition and declaration, workspace, and many more.<\/p>\n\n\n\n<p>If have not <a href=\"https:\/\/smarttech101.com\/how-to-configure-neovim\/\" target=\"_blank\" rel=\"noreferrer noopener\">set up basic configuration in Neovim, do that over here<\/a>. This article is part of my series on setting up Nvim Lsp (Neovim Language Server Protocol):<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Nvim lsp: configure language servers, shortcuts for listing your symbols, rename, code actions, get definition\/declaration, workspace, highlights (this article)<\/li>\n\n\n\n<li><a href=\"https:\/\/smarttech101.com\/nvim-lsp-diagnostics-keybindings-signs-virtual-texts\/\" target=\"_blank\" rel=\"noreferrer noopener\">Nvim lsp: diagnostics &#8211; keybindings, error\/warning signs, floating and virtual texts<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/smarttech101.com\/nvim-lsp-autocompletion-mapping-snippets-fuzzy-search\/\" target=\"_blank\" rel=\"noreferrer noopener\">Nvim lsp: autocompletion &#8211; mapping, snippets, fuzzy search, and icons<\/a><\/li>\n<\/ol>\n\n\n\n<p>I recommend you to follow all three articles in the above order.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#what_are_language_server_and_lsp\">What are Language Server and LSP<\/a><\/li>\n\n\n\n<li><a href=\"#install_necessary_plugins_for_nvim_lsp\">Install useful plug-ins for nvim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#install_necessary_language_servers\">Install necessary language servers<\/a><\/li>\n\n\n\n<li><a href=\"#set_up_key_bindings_in_neovimlsp\">Set up key bindings in neovim-lsp<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#definition_and_declaration_in_nvim_lsp\">Definition and Declaration in neovim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#hover_information_in_nvim_lsp\">Hover information in neovim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#implementation_in_nvim_lsp\">Implementation in nvim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#signature_help_in_nvim_lsp\">Signature help in neovim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#workspace_in_nvim_lsp\">Workspace in neovim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#rename_symbols_in_nvim_lsp\">Rename symbols in neovim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#code_actions_in_nvim_lsp\">Code actions in nvim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#list_all_references_to_the_symbol_using_nvim_lsp\">List all references to the symbol using neovim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#formatting_in_nvim_lsp\">Formatting in nvim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#get_information_about_language_servers_attached_to_neovim\">Get information about language servers attached to neovim<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#highlight_symbol_under_the_cursor_using_nvim_lsp\">Highlight symbol under the cursor using nvim lsp<\/a><\/li>\n\n\n\n<li><a href=\"#language_server_configurations\">Language Server Configurations<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#configure_several_language_servers_at_once_in_nvim\">Configure several language servers at once in nvim<\/a><\/li>\n\n\n\n<li><a href=\"#configure_each_server_separately\">Configure each server separately in nvim-lsp<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#way_ahead\">Way Ahead<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what_are_language_server_and_lsp\">What are Language Server and LSP<\/h2>\n\n\n\n<p><strong>Language Servers<\/strong>, like any other servers, run in the background of your computer and they serve their services such as autocompletion, diagnostics (linting), formatting, hover information, renaming, etc. to any &#8216;<strong>client<\/strong>&#8216; such as <strong>neovim<\/strong>\/vscode\/atom\/sublime. These services are served by following a special communication protocol called <a href=\"https:\/\/microsoft.github.io\/language-server-protocol\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Language Server Protocol<\/a>.<\/p>\n\n\n\n<p>LSP is a rather new protocol and most modern editors are starting to support this. As of 10 June 2022, Vim still does not support this natively. You need to install special plugins in vim for this feature. But <strong>neovim, starting from version 0.5<\/strong>, has started to support this in its core version itself (use the command <code>nvim --version<\/code> to find your version of neovim). You don&#8217;t have to install any plugin in neovim for this. At the same time, there are some related plug-ins in neovim which makes configuring and using language servers easy. I will be recommending such plug-ins in the upcoming paras.<\/p>\n\n\n\n<p>For each famous programming language, we have at least one language server. For example, <code>bash-language-server<\/code> (sometimes also called <code>bashls<\/code>) is for <code>bash<\/code> language, <code>pyright<\/code> is for <code>python<\/code> language, <code>lua-language-server<\/code> (also known as <code>sumneko_lua<\/code>) for <code>lua<\/code> language.<\/p>\n\n\n\n<p>Before language servers came into existence, each editor needed to provide dedicated support for each language in its own unique way. It was a cumbersome process. But now, language developers only need to develop the language and the corresponding server. And editors supporting LSP can connect with these servers without having any dedicated support for the language itself.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"install_necessary_plugins_for_nvim_lsp\">Install useful plug-ins for nvim lsp<\/h2>\n\n\n\n<p>Use your favorite plug-in managers to install these plug-ins:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>collection of configurations for builtin neovim-lsp: <code>neovim\/nvim-lspconfig<\/code><\/li>\n\n\n\n<li>Plug-in <code>hrsh7th\/nvim-cmp<\/code> provides additional completion capabilities.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"install_necessary_language_servers\">Install necessary language servers<\/h2>\n\n\n\n<p>In this article, I will explain everything using the <code>lua-language-server<\/code>, <code>pyright<\/code> (<code>python-language-server<\/code>) and <code>bash-language-server<\/code>. For others, the procedure is exactly similar. To get a list of available servers, visit the <a href=\"https:\/\/github.com\/neovim\/nvim-lspconfig\/blob\/master\/doc\/server_configurations.md\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">neovim site for server configuration<\/a>.<\/p>\n\n\n\n<p>There are many ways to install the servers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Using your distributions&#8217; official package managers <\/strong>(ex &#8211; <code>apt<\/code> for Debian, <code>pacman<\/code> for Arch Linux). This is <strong>best<\/strong> of all because now, the packages will be upgraded by your package managers and you don&#8217;t have to do that manually.<\/li>\n\n\n\n<li>However, If you cannot install it using the above method, just search on Google, <strong>head over to the official sites <\/strong>of these servers, and follow the recommended methods.<\/li>\n<\/ul>\n\n\n\n<p>Arch Linux:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pacman -S bash-language-server lua-language-server pyright<\/code><\/pre>\n\n\n\n<p>Other distributions\/OSes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install pyright\nnpm i -g bash-language-server\nbrew install lua-language-server\nport install lua-language-server<\/code><\/pre>\n\n\n\n<p>After installing the servers, you need to set up Key Bindings and Highlights and then server configurations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"set_up_key_bindings_in_neovimlsp\">Set up key bindings in neovim-lsp<\/h2>\n\n\n\n<p>First, you need to create a file <code>~\/.config\/nvim\/plug-config\/lspconfig.lua<\/code>. Now, you need to populate it with configuration. In the very end, I will show you how to &#8216;source&#8217; it in your <code>init.vim<\/code>. Only after that, you will see any result.<\/p>\n\n\n\n<p>In the file <code>~\/.config\/nvim\/plug-config\/lspconfig.lua<\/code>, first, create an <code>on_attach<\/code> function, then put your keybindings into it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>local on_attach = function(client, bufnr)\n  local opts = { noremap = true, silent = true }\n  KEY_BINDING_1\n  KEY_BINDING_2\nend<\/code><\/pre>\n\n\n\n<p>Where, <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>KEY_BINDING_1, 2, &#8230; will be replaced by your keybindings.<\/li>\n\n\n\n<li><code>opt<\/code> variable will be used in setting up your keybindings.<\/li>\n\n\n\n<li>Putting the key-bindings inside the <code>on_attach<\/code> function makes sure that these<strong> <\/strong>key-bindings are only created when there is any Language Server attached to the neovim. In our example, we will be configuring the servers only for lua, bash, and python. So, when you open any file with filetypes other than lua, bash and python, these key-bindings will not take any action.<\/li>\n\n\n\n<li>You can refer to neovim&#8217;s help page using <code>:help nvim_buf_set_keymap()<\/code> for more information.<\/li>\n<\/ul>\n\n\n\n<p>Now, I will help you populate your <code>on_attach<\/code> function with the necessary key bindings.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"symbols_in_nvimlsp\">Symbols in nvim-lsp<\/h3>\n\n\n\n<p>Symbols are special keywords in your code such as variables, functions, etc. To get a list of the symbols, execute the command <code>:lua vim.lsp.buf.document_symbol()<\/code>.<\/p>\n\n\n\n<p>To bind the command with the key <code>&lt;leader&gt;ls<\/code>, put the following code inside your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;ls', '&lt;cmd&gt;lua vim.lsp.buf.document_symbol()&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"definition_and_declaration_in_nvim_lsp\">Definition and Declaration in nvim lsp<\/h3>\n\n\n\n<p><strong>Definition<\/strong>: When you put your cursor on any &#8216;symbol&#8217; and execute the vim command <code>lua vim.lsp.buf.definition()<\/code>, your cursor will move to the definition of the symbol. This is quite handy for big projects spread over a large number of files and lines.<\/p>\n\n\n\n<p><strong>Declaration<\/strong> (<code>:lua vim.lsp.buf.declaration()<\/code>): many servers do not support the Declaration. Most of the time, Definition is enough.<\/p>\n\n\n\n<p>To bind the above definition and declaration command with the keys <code>&lt;leader&gt;ld<\/code> and <code>&lt;leader&gt;lD<\/code>, put the following code inside your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lD', '&lt;cmd&gt;lua vim.lsp.buf.declaration()&lt;CR&gt;', opts)\nvim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;ld', '&lt;cmd&gt;lua vim.lsp.buf.definition()&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"hover_information_in_nvim_lsp\">Hover information in nvim lsp<\/h3>\n\n\n\n<p>Hover information gives you a help document in a floating window when you &#8216;hover&#8217; your cursor on any special keyword. For example, in bash language, hovering on <code>find<\/code> command will give you find&#8217;s man page, in python language, hovering on <code>print()<\/code> will give you short information about the print function.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"458\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/nvim-lsp-hover.png?resize=731%2C458&#038;ssl=1\" alt=\"hover in nvim lsp: just put your cursor on any symbol (here path) and execute the hover command to get the hover information.\" class=\"wp-image-2092\"\/><figcaption class=\"wp-element-caption\">fig 1: hover in nvim lsp: just put your cursor on any symbol (here <code>path<\/code>) and execute the hover command to get the hover information.<\/figcaption><\/figure>\n\n\n\n<p>To bind the hover command <code>:lua vim.lsp.buf.hover()<\/code> with the key <code>&lt;leader&gt;lk<\/code>, put the following code in your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lk', '&lt;cmd&gt;lua vim.lsp.buf.hover()&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<p>Please note that &#8220;hovering&#8221; in neovim is slightly different. Here, you first need to put your cursor instead of just hover on the symbol and then press <code>&lt;leader&gt;lk<\/code>. Press this shortcut key again and you will reach into the floating &#8216;window&#8217;. To get out of the floating window, quit (<code>:q<\/code>) as usual.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"implementation_in_nvim_lsp\">Implementation in nvim lsp<\/h3>\n\n\n\n<p>Executing the neovim command <code>:lua vim.lsp.buf.implementation()<\/code> on any symbol will list all the <strong>implementations<\/strong> for the symbol under the cursor in the quickfix window. <\/p>\n\n\n\n<p>However, if your language server does not support this you might see the message <code>method textDocument\/implementation is not supported by any of the servers registered for the current buffer<\/code> at the bottom of your neovim. For your information, the bash-language-server, lua-language-server, and <a href=\"https:\/\/neovim.discourse.group\/t\/pyright-go-to-implementation-not-working\/1336\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">pyright do not support implementations<\/a>.<\/p>\n\n\n\n<p>To bind this command with the key <code>&lt;leader&gt;lI<\/code>, put the following code in your <code>attach_function<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lI', '&lt;cmd&gt;lua vim.lsp.buf.implementation()&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"signature_help_in_nvim_lsp\">Signature help in nvim lsp<\/h3>\n\n\n\n<p>Signature help shows information about the parameters of your function\/method in a floating window. For example, suppose you have defined a function with a list of parameters (or variables). When you start to type the parameters&#8217; values one after another, some helpful information will be shown in a floating window.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"929\" height=\"382\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/nvim-lsp-signature-help.png?resize=929%2C382&#038;ssl=1\" alt=\"signature help in nvim lsp\" class=\"wp-image-2091\" srcset=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/nvim-lsp-signature-help.png?w=929&amp;ssl=1 929w, https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/nvim-lsp-signature-help.png?resize=768%2C316&amp;ssl=1 768w\" sizes=\"(max-width: 929px) 100vw, 929px\" \/><figcaption class=\"wp-element-caption\">fig 2: signature help in nvim lsp<\/figcaption><\/figure>\n\n\n\n<p>To bind the signature help command <code>:lua vim.lsp.buf.signature_help()<\/code> with the key <code>&lt;leader&gt;lsh<\/code>, use the following code in your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lsh', '&lt;cmd&gt;lua vim.lsp.buf.signature_help()&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<p>However, personally, I find it less useful than using another plug-in <code>hrsh7th\/cmp-nvim-lsp-signature-help<\/code>. The plug-in gives the signature-help in the floating window without using any shortcut key. On top of that, the plug-in also boaldens the variable under consideration (in figure 2, <code>var2<\/code> is shown in bold in the floating window as I am about to write its value). I will cover more about signature-help in the next article on <a href=\"https:\/\/smarttech101.com\/nvim-lsp-autocompletion-mapping-snippets-fuzzy-search\/\" target=\"_blank\" rel=\"noreferrer noopener\">nvim-lsp autocompletion<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"workspace_in_nvim_lsp\">Workspace in nvim lsp<\/h3>\n\n\n\n<p>A &#8220;<strong>workspace<\/strong>&#8221; is the collection of one or more folders that are opened in your window (source: <a href=\"https:\/\/code.visualstudio.com\/docs\/editor\/workspaces.\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Workspace in vscode<\/a>).<\/p>\n\n\n\n<p>To have keybindings for add, remove, and list workspaces, use the following code in your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lwa', '&lt;cmd&gt;lua vim.lsp.buf.add_workspace_folder()&lt;CR&gt;', opts)\nvim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lwr', '&lt;cmd&gt;lua vim.lsp.buf.remove_workspace_folder()&lt;CR&gt;', opts)\nvim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lwl', '&lt;cmd&gt;lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"rename_symbols_in_nvim_lsp\">Rename symbols in nvim lsp<\/h3>\n\n\n\n<p>The command <code>:lua vim.lsp.buf.rename()<\/code> only <strong>renames<\/strong> all references to the symbol under the cursor. It does not rename the string in other places such as comments.<\/p>\n\n\n\n<p>To bind this command with the key <code>&lt;leader&gt;lr<\/code>, put the following code in your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lr', '&lt;cmd&gt;lua vim.lsp.buf.rename()&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"code_actions_in_nvim_lsp\">Code actions in nvim lsp<\/h3>\n\n\n\n<p>When you write your projects, you might encounter errors\/warnings. Code actions in that case are available suggestions to fix\/remove these errors and warnings. Not all language servers provide this service.<\/p>\n\n\n\n<p>To bind the key <code>&lt;leader&gt;lc<\/code> with the command <code>:lua vim.lsp.buf.code_action()<\/code>, use the following code in your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lc', '&lt;cmd&gt;lua vim.lsp.buf.code_action()&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<p>Now press <code>&lt;leader&gt;lc<\/code> on any symbol\/line with an error\/warning, it would show you possible <strong>code actions<\/strong> (like how to solve\/remove the error\/warning) you can do. It gives a list of actions in command line mode and you have to enter a number to choose the action.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"458\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/nvim-lsp-code-action.png?resize=731%2C458&#038;ssl=1\" alt=\"code actions in nvim-lsp (shown at the bottom)\" class=\"wp-image-2090\"\/><figcaption class=\"wp-element-caption\">fig 3: code actions in nvim-lsp (shown at the bottom)<\/figcaption><\/figure>\n\n\n\n<p>Sometimes, code actions are available even if there is no error\/warning\/information\/hint. In that case, you can show a lightbulb using <code>kosayoda\/nvim-lightbulb<\/code> plug-in.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"list_all_references_to_the_symbol_using_nvim_lsp\">List all references to the symbol using nvim lsp<\/h3>\n\n\n\n<p>Nvim lsp command <code>:lua vim.lsp.buf.references()<\/code> on any symbol under the cursor lists all the <strong>references<\/strong> to the symbol in a quickfix window.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"458\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/nvim-lsp-references-1.png?resize=731%2C458&#038;ssl=1\" alt=\"references to the symbol filename in the quickfix window shown in red.\" class=\"wp-image-2089\"\/><figcaption class=\"wp-element-caption\">fig 4: references to the symbol <code>filename<\/code> in the quickfix window shown in red.<\/figcaption><\/figure>\n\n\n\n<p>To bind this command with <code>&lt;leader&gt;lR<\/code>, put the following code in your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lR', '&lt;cmd&gt;lua vim.lsp.buf.references()&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"formatting_in_nvim_lsp\">Formatting in nvim lsp<\/h3>\n\n\n\n<p>Formatting removes\/enters unnecessary spaces, newline characters, etc., and thus makes your code look soothing to the eyes.<\/p>\n\n\n\n<p>To bind the formatting command <code>:lua vim.lsp.buf.formatting()<\/code> with the key <code>&lt;leader&gt;lf<\/code>, use the following code in your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;lf', '&lt;cmd&gt;lua vim.lsp.buf.formatting()&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<p>However, only a few language servers (ex &#8211; lua-language-server) provide formatting but others (ex &#8211; bash-language-server) don&#8217;t. So, use a plug-in called null-ls which kind of merges formatters with language servers. For example, bash-language-server does not provide formatting. Therefore by using <code>null-ls<\/code>, you can &#8220;bring&#8221; the formatting ability into this from a separate formatter <a href=\"https:\/\/github.com\/mvdan\/sh\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">shfmt<\/a>. To use it, head over to my <a href=\"https:\/\/smarttech101.com\/nvim-lsp-set-up-null-ls-for-beginners\/\" target=\"_blank\" rel=\"noreferrer noopener\">in-depth article on null-ls<\/a>.<\/p>\n\n\n\n<p><strong>Note 1:<\/strong> Please note that the formatting command is a little different in nvim v 0.8:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- 0.7\nvim.lsp.buf.formatting_sync(nil, 2000) -- 2 seconds\n\n-- 0.8\nvim.lsp.buf.format({ timeout_ms = 2000 }) -- 2 seconds<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"get_information_about_language_servers_attached_to_neovim\">Get information about language servers attached to neovim<\/h3>\n\n\n\n<p>The neovim command <code>LspInfo<\/code> prints detected filetype, attached language servers, root directory, etc. in a floating window.<\/p>\n\n\n\n<p>To bind this command with the key <code>&lt;leader&gt;li<\/code>, put the following code in your <code>on_attach<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim.api.nvim_buf_set_keymap(bufnr, 'n', '&lt;leader&gt;li', '&lt;cmd&gt;LspInfo&lt;CR&gt;', opts)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"highlight_symbol_under_the_cursor_using_nvim_lsp\">Highlight symbol under the cursor using nvim lsp<\/h2>\n\n\n\n<p>When you put your cursor on any one symbol, the symbol is highlighted everywhere.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"458\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/highlight-nvim-lsp-1.png?resize=731%2C458&#038;ssl=1\" alt=\"highlight your symbol under cursor\" class=\"wp-image-2088\"\/><figcaption class=\"wp-element-caption\">fig 5: highlight your symbol <code>filename<\/code> under  the cursor<\/figcaption><\/figure>\n\n\n\n<p>To highlight the symbol under the cursor, put the following code in the same file <code>~\/.config\/nvim\/plug-config\/lspconfig.lua<\/code>. <strong>Please note that these lines should go into the <code>on_attach<\/code> function.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  if client.resolved_capabilities.document_highlight then\n    vim.cmd &#91;&#91;\n      hi! LspReferenceRead cterm=bold ctermbg=235 guibg=LightYellow\n      hi! LspReferenceText cterm=bold ctermbg=235 guibg=LightYellow\n      hi! LspReferenceWrite cterm=bold ctermbg=235 guibg=LightYellow\n    ]]\n    vim.api.nvim_create_augroup('lsp_document_highlight', {})\n    vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {\n      group = 'lsp_document_highlight',\n      buffer = 0,\n      callback = vim.lsp.buf.document_highlight,\n    })\n    vim.api.nvim_create_autocmd('CursorMoved', {\n      group = 'lsp_document_highlight',\n      buffer = 0,\n      callback = vim.lsp.buf.clear_references,\n    })\n  end<\/code><\/pre>\n\n\n\n<p>As you can see I am using the <code>if..end<\/code> condition for highlighting. This prevents neovim from asking the language server to highlight your symbol if the server does not have this ability.<\/p>\n\n\n\n<p><strong>Edit 15\/11\/2022: For Neovim 0.8 or above, use <code>client.server_capabilities.documentHighlightProvider<\/code><\/strong> <strong>instead of <code>client.resolved_capabilities.document_highlight<\/code><\/strong>.<\/p>\n\n\n\n<p>\ud83d\udcd3<strong>Note<\/strong>: You can change the <code>ctermbg<\/code> and\/or <code>guibg<\/code> to get the appropriate highlighting color. Similarly, you can also use italics instead of bold, provided your terminal supports it.<\/p>\n\n\n\n<p>I also recommend you to look at this article on <a href=\"https:\/\/smarttech101.com\/how-to-configure-colorscheme-in-vim-neovim\/\" target=\"_blank\" rel=\"noreferrer noopener\">Neovim colorscheme, highlighting various components, etc<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"language_server_configurations\">Language Server Configurations<\/h2>\n\n\n\n<p>The <code>nvim-cmp<\/code> supports additional completion &#8216;capabilities&#8217;. To use these capabilities as well, put the following code in your file <code>~\/.config\/nvim\/plug-config\/lspconfig.lua<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())<\/code><\/pre>\n\n\n\n<p><strong>For Neovim v0.8 or above, use <code>default_capabilities()<\/code> instead of <code>update_capabilities(vim.lsp.protocol.make_client_capabilities())<\/code><\/strong>. <\/p>\n\n\n\n<p>I will talk more about nvim-cmp in my next article on <a href=\"https:\/\/smarttech101.com\/nvim-lsp-autocompletion-mapping-snippets-fuzzy-search\/\" target=\"_blank\" rel=\"noreferrer noopener\">neovim lsp autocompletion<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure_several_language_servers_at_once_in_nvim\">Configure several language servers at once in nvim<\/h3>\n\n\n\n<p>Now, you can use a loop to call &#8216;setup&#8217; on multiple servers and map key-bindings only after the language server attaches. For this, use the following code in your file <code>~\/.config\/nvim\/plug-config\/lspconfig.lua<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>local servers = { 'pyright', }\nfor _, lsp in ipairs(servers) do\n  require('lspconfig')&#91;lsp].setup {\n    on_attach = on_attach,\n    capabilities = capabilities,\n  }\nend<\/code><\/pre>\n\n\n\n<p>In the above code, you can see that the variable <code>servers<\/code> is an array whose elements are the servers you want to loop into. For example, if you use <code>local servers = { 'bashls', 'pyright', 'sumneko_lua', }<\/code>, you can configure the servers <code>bash-language-server<\/code>, <code>pyright<\/code>, and <code>lua-language-server<\/code> at once.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure_each_server_separately\">Configure each server separately in nvim lsp<\/h3>\n\n\n\n<p>For example, the following code in the file <code>~\/.config\/nvim\/plug-config\/lspconfig.lua<\/code> attaches only the <code>bash-language-server<\/code> with the file-types <code>zsh<\/code>, <code>bash<\/code> and <code>sh<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- bashls\nrequire 'lspconfig'.bashls.setup {\n  on_attach = on_attach,\n  capabilities = capabilities,\n  filetypes = { 'zsh', 'bash', 'sh' },\n}<\/code><\/pre>\n\n\n\n<p>Similarly, you can also configure the lua-language-server server in its own unique way:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>local runtime_path = vim.split(package.path, ';')\ntable.insert(runtime_path, \"lua\/?.lua\")\ntable.insert(runtime_path, \"lua\/?\/init.lua\")\nrequire 'lspconfig'.sumneko_lua.setup {\n  on_attach = on_attach,\n  capabilities = capabilities,\n  settings = {\n    Lua = {\n      runtime = {\n        -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)\n        version = 'LuaJIT',\n        -- Setup your lua path\n        path = runtime_path,\n      },\n      diagnostics = {\n        -- Get the language server to recognize the `vim` global\n        -- Now, you don't get error\/warning \"Undefined global `vim`\".\n        globals = { 'vim' },\n      },\n      workspace = {\n        -- Make the server aware of Neovim runtime files\n        library = vim.api.nvim_get_runtime_file(\"\", true),\n      },\n      -- By default, lua-language-server sends anonymized data to its developers. Stop it using the following.\n      telemetry = {\n        enable = false,\n      },\n    },\n  },\n}<\/code><\/pre>\n\n\n\n<p>The above lua-language-server&#8217;s configuration helps you develop\/work with neovim plug-ins.<\/p>\n\n\n\n<p><strong>Note<\/strong>: Head over to the <a href=\"https:\/\/github.com\/neovim\/nvim-lspconfig\/blob\/master\/doc\/server_configurations.md\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">neovim site for server configuration<\/a> to get the list of servers and how to configure them.<\/p>\n\n\n\n<p><strong>Update (25 August 2023):<\/strong><\/p>\n\n\n\n<p><strong>Issue 1: Warning\/Error &#8220;sumneko_lua is deprecated, use lua_ls instead&#8221; shown at the bottom whenever you open any lua file.<\/strong><\/p>\n\n\n\n<p><strong>Quick Fix: <\/strong>Replace <code>sumneko_lua<\/code> term in the above snippet with <code>lua_ls<\/code>. If you have any related questions, ask them in the comment section below.<\/p>\n\n\n\n<p><strong>Issue 2:<\/strong> Each time you open any lua file, you are faced with the following prompts:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Do you need to configure your work environment as `luassert`?\nRequest Actions:\n1. Apply and modify settings\n2. Apply but do not modify settings\n3. Don't show again\nType number and &lt;Enter> or click with the mouse (q or empty cancels):<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Do you need to configure your work environment as `luv`?:\n1: Apply and modify settings\n2: Apply but do not modify settings\n3: Don't show again\nType number and &lt;Enter> or click with the mouse (q or empty cancels):<\/code><\/pre>\n\n\n\n<p><strong>Fix:<\/strong> If you don&#8217;t know what L\u00d6VE\/ Luv, and Luassert are, chances are you don&#8217;t need them. So, disable them permanently &#8211; this way additional completions and intellisense will not be loaded making lua-language-server lighter.<a href=\"https:\/\/github.com\/LuaLS\/lua-language-server\/issues\/679#issuecomment-925524834\" target=\"_blank\" rel=\"noreferrer noopener nofollow\"> Choose 3 to disable it. However, somehow, choosing 3 is only working on VSCode, not in Neovim<\/a>. For neovim, disable it manually using the lspconfig.lua file. Just add <code>checkThirdParty = false,<\/code> into the <code>workspace = {...}<\/code> like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>      workspace = {\n        library = vim.api.nvim_get_runtime_file(\"\", true),\n        checkThirdParty = false,\n      },<\/code><\/pre>\n\n\n\n<p>For those, who know what they are, enable them only on those projects where they are actually needed. <a href=\"https:\/\/www.reddit.com\/r\/neovim\/comments\/wgu8dx\/configuring_neovim_for_l\u00f6velua_i_always_get\/ij5rgxg\/?utm_source=share&amp;utm_medium=web3x&amp;utm_name=web3xcss&amp;utm_term=1&amp;utm_content=share_button\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">I found a good Reddit instruction over here.<\/a> In summary, create a file named <code>.luarc.json<\/code> in the root of your project and add the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n\t\"workspace\": {\n\t\t\"library\": &#91;\n\t\t\t\"&lt;path-to-love-library>\", \"&lt;path-to-luassert-library>\"\n\t\t]\n\t}\n}<\/code><\/pre>\n\n\n\n<p>To find the paths, you need to look at the places where lua-language-server is installed and browse through them. You can also use <code>locate<\/code> command in linux to search for these paths. In archlinux, these paths are &#8211; <code>\/usr\/lib\/lua-language-server\/meta\/3rd\/luassert<\/code> and <code>\/usr\/lib\/lua-language-server\/meta\/3rd\/love2d<\/code>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"way_ahead\">Way Ahead<\/h2>\n\n\n\n<p>That&#8217;s all folks for nvim-LSP configuration. And don&#8217;t forget to source the file <code>~\/.config\/nvim\/plug-config\/lspconfig.lua<\/code> in your <code>init.vim<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source $HOME\/.config\/nvim\/plug-config\/lspconfig.lua<\/code><\/pre>\n\n\n\n<p>In order to completely set up your Nvim-lsp, please go through all articles in the <a href=\"https:\/\/smarttech101.com\/tag\/nvim-lsp\/\" target=\"_blank\" rel=\"noreferrer noopener\">nvim-lsp series<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nvim-lsp: learn what are language server and lsp, set up language servers in neovim, highlight symbol under the cusor, keybindings for code actions, rename, hover info, implementations, definition and declaration, workspace<\/p>\n","protected":false},"author":2,"featured_media":2097,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[37],"tags":[40,39,41],"class_list":["post-2087","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-neovim","tag-neovim","tag-nvim","tag-nvim-lsp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nvim lsp: configure language servers, shortcuts, highlights | SmartTech101<\/title>\n<meta name=\"description\" content=\"Learn what is language server; setup nvim lsp: key-bindings, highlight your symbol under the cursors, configure your servers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nvim lsp: configure language servers, shortcuts, highlights | SmartTech101\" \/>\n<meta property=\"og:description\" content=\"Learn what is language server; setup nvim lsp: key-bindings, highlight your symbol under the cursors, configure your servers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/\" \/>\n<meta property=\"og:site_name\" content=\"SmartTech101\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-11T22:05:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-25T12:03:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"705\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ajay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ajay_yadav\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/\"},\"author\":{\"name\":\"Ajay\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\"},\"headline\":\"Nvim lsp: configure language servers, shortcuts, highlights\",\"datePublished\":\"2022-06-11T22:05:17+00:00\",\"dateModified\":\"2023-08-25T12:03:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/\"},\"wordCount\":2285,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png?fit=1280%2C705&ssl=1\",\"keywords\":[\"neovim\",\"nvim\",\"nvim-lsp\"],\"articleSection\":[\"Neovim\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/\",\"url\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/\",\"name\":\"Nvim lsp: configure language servers, shortcuts, highlights | SmartTech101\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png?fit=1280%2C705&ssl=1\",\"datePublished\":\"2022-06-11T22:05:17+00:00\",\"dateModified\":\"2023-08-25T12:03:03+00:00\",\"description\":\"Learn what is language server; setup nvim lsp: key-bindings, highlight your symbol under the cursors, configure your servers.\",\"breadcrumb\":{\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png?fit=1280%2C705&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png?fit=1280%2C705&ssl=1\",\"width\":1280,\"height\":705,\"caption\":\"Nvim-Lsp: Key-Bindings, Symbol Highlighting, Server Configurations\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/smarttech101.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nvim lsp: configure language servers, shortcuts, highlights\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/smarttech101.com\/#website\",\"url\":\"https:\/\/smarttech101.com\/\",\"name\":\"SmartTech101\",\"description\":\"Do Everything in Linux\",\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/smarttech101.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\",\"name\":\"Ajay Yadav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"width\":180,\"height\":60,\"caption\":\"Ajay Yadav\"},\"logo\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\",\"name\":\"Ajay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"caption\":\"Ajay\"},\"sameAs\":[\"https:\/\/x.com\/ajay_yadav\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nvim lsp: configure language servers, shortcuts, highlights | SmartTech101","description":"Learn what is language server; setup nvim lsp: key-bindings, highlight your symbol under the cursors, configure your servers.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/","og_locale":"en_US","og_type":"article","og_title":"Nvim lsp: configure language servers, shortcuts, highlights | SmartTech101","og_description":"Learn what is language server; setup nvim lsp: key-bindings, highlight your symbol under the cursors, configure your servers.","og_url":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/","og_site_name":"SmartTech101","article_published_time":"2022-06-11T22:05:17+00:00","article_modified_time":"2023-08-25T12:03:03+00:00","og_image":[{"width":1280,"height":705,"url":"https:\/\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png","type":"image\/png"}],"author":"Ajay","twitter_card":"summary_large_image","twitter_creator":"@ajay_yadav","twitter_misc":{"Written by":"Ajay","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#article","isPartOf":{"@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/"},"author":{"name":"Ajay","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334"},"headline":"Nvim lsp: configure language servers, shortcuts, highlights","datePublished":"2022-06-11T22:05:17+00:00","dateModified":"2023-08-25T12:03:03+00:00","mainEntityOfPage":{"@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/"},"wordCount":2285,"commentCount":0,"publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"image":{"@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png?fit=1280%2C705&ssl=1","keywords":["neovim","nvim","nvim-lsp"],"articleSection":["Neovim"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/","url":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/","name":"Nvim lsp: configure language servers, shortcuts, highlights | SmartTech101","isPartOf":{"@id":"https:\/\/smarttech101.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#primaryimage"},"image":{"@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png?fit=1280%2C705&ssl=1","datePublished":"2022-06-11T22:05:17+00:00","dateModified":"2023-08-25T12:03:03+00:00","description":"Learn what is language server; setup nvim lsp: key-bindings, highlight your symbol under the cursors, configure your servers.","breadcrumb":{"@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#primaryimage","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png?fit=1280%2C705&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png?fit=1280%2C705&ssl=1","width":1280,"height":705,"caption":"Nvim-Lsp: Key-Bindings, Symbol Highlighting, Server Configurations"},{"@type":"BreadcrumbList","@id":"https:\/\/smarttech101.com\/nvim-lsp-configure-language-servers-shortcuts-highlights\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smarttech101.com\/"},{"@type":"ListItem","position":2,"name":"Nvim lsp: configure language servers, shortcuts, highlights"}]},{"@type":"WebSite","@id":"https:\/\/smarttech101.com\/#website","url":"https:\/\/smarttech101.com\/","name":"SmartTech101","description":"Do Everything in Linux","publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smarttech101.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633","name":"Ajay Yadav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","width":180,"height":60,"caption":"Ajay Yadav"},"logo":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334","name":"Ajay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","caption":"Ajay"},"sameAs":["https:\/\/x.com\/ajay_yadav"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/06\/Nvim-Lsp-Key-Bindings-Symbol-Highlighting-Server-Configurations.png?fit=1280%2C705&ssl=1","_links":{"self":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/2087"}],"collection":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/comments?post=2087"}],"version-history":[{"count":4,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/2087\/revisions"}],"predecessor-version":[{"id":3045,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/2087\/revisions\/3045"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media\/2097"}],"wp:attachment":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media?parent=2087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/categories?post=2087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/tags?post=2087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}