Code Navigation

LSP

To make nvim "smart" you need to install a LSP server and connect it to nvim's LSP client.

There are two options to do that:

  1. Using mason.nvim with mason-lspconfig.nvim and nvim-lspconfig, these 3 plugins will manage and install LSP servers, make sure you integrate it with your preconfigured configuration.
  2. Using nvim-lspconfig and manually maintain the LSP servers binaries (personally I do it with dotfiles), make sure you integrate it with your preconfigured configuration.

Telescope

Now we need a tool which can utilize the great capabilities that are provided with LSP.

One of them is telescope which is a framework for search, preview and pick.

Some of the features:

  • You can live-grep across the project with it, equivalent to CTRL+SHIFT+F in a "modern" IDE.
  • You can find a file, equivalent to CTRL+p in a "modern" IDE.
  • You can find all the definitions of a function with it (using LSP), equivalent to F12 in a "modern" IDE.
  • You can find all the references/implementations/type definitions with it (using LSP).
  • You can live grep a local/workspace symbols (functions), using LSP ofc.

Your preconfigured configuration probably has it installed and binded to keys already, make sure you know how to use it and configure it to your taste, it is very useful.

LSP Goodies

  • LSP Saga UI for LSP "hover" and rename and code actions (hints).
  • vim-illuminate highlight the symbol your cursor is on and let you jump to next/previous reference, very useful to know what "happened" to a variable.
  • LSP Signature shows the function signature while writing a function call.
  • fidget.nvim shows the LSP server progress in the bottom right corner.
  • lsp_lines.nvim shows the diagnostics in an intuitive way.
  • trld.nvim shows the current line diagnostic in the top right corner of the buffer.
  • nvim-navic shows the current context in the status/winbar line.
  • More plugins that integrate with LSP