Giter Club home page Giter Club logo

nvim-lsp-installer's Introduction

nvim-lsp-installer

About

Companion plugin for nvim-lspconfig that allows you to seamlessly install LSP servers locally (inside :echo stdpath("data")).

On top of just providing commands for installing & uninstalling LSP servers, it:

  • provides a graphical UI
  • optimized for blazing fast startup times
  • supports installing custom versions of LSP servers (for example :LspInstall rust_analyzer@nightly)
  • common install tasks are abstracted behind composable Lua APIs (has direct integration with libuv via vim.loop)
  • minimum requirements are relaxed by attempting multiple different utilities (for example, only one of wget, curl, or Invoke-WebRequest is required for HTTP requests)
  • full support for Windows

Installation

Requires neovim >= 0.5.0 and nvim-lspconfig. The full requirements to install all servers are:

  • For Unix systems: bash(1), git(1), curl(1) or wget(1), unzip(1), tar(1), gzip(1)
  • For Windows systems: powershell, git, tar, and 7zip or peazip or archiver or winzip
  • Node.js (LTS) & npm
  • Python3 & pip3
  • go
  • javac
  • Ruby & gem
use {
    'neovim/nvim-lsp-config',
    'williamboman/nvim-lsp-installer',
}

vim-plug

Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'

Usage

Commands

  • :LspInstallInfo - opens a graphical overview of your language servers
  • :LspInstall <server> ... - installs/reinstalls language servers
  • :LspUninstall <server> ... - uninstalls language servers
  • :LspUninstallAll - uninstalls all language servers
  • :LspInstallLog - opens the log file in a new tab window
  • :LspPrintInstalled - prints all installed language servers

Setup

local lsp_installer = require("nvim-lsp-installer")

lsp_installer.on_server_ready(function(server)
    local opts = {}

    -- (optional) Customize the options passed to the server
    -- if server.name == "tsserver" then
    --     opts.root_dir = function() ... end
    -- end

    -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
    server:setup(opts)
    vim.cmd [[ do User LspAttachBuffers ]]
end)

For more advanced use cases you may also interact with more APIs nvim-lsp-installer has to offer, for example the following (refer to :help nvim-lsp-installer for more docs):

local lsp_installer_servers = require'nvim-lsp-installer.servers'

local ok, rust_analyzer = lsp_installer_servers.get_server("rust_analyzer")
if ok then
    if not rust_analyzer:is_installed() then
        rust_analyzer:install()
    end
end

Configuration

You can configure certain behavior of nvim-lsp-installer by calling the .settings() function. Refer to the default configuration for all available settings.

Example:

require("nvim-lsp-installer").settings {
    ui = {
        icons = {
            server_installed = "",
            server_pending = "",
            server_uninstalled = ""
        }
    }
}

Available LSPs

Language Server name
Angular angularls
Ansible ansiblels
Bash bashls
Bicep bicep
C# omnisharp
C++ clangd
CMake cmake
CSS cssls
Clojure clojure_lsp
Deno denols
Diagnostic (general purpose server) diagnosticls
Dlang serve_d
Docker dockerls
Dot dotls
EFM (general purpose server) efm
ESLint (docs) eslint
Elixir elixirls
Elm elmls
Ember ember
Emmet emmet_ls
Erlang erlangls
Fortran fortls
Go gopls
GraphQL graphql
Groovy groovyls
HTML html
Haskell hls
JSON jsonls
Java jdtls
Jedi jedi_language_server
Kotlin kotlin_language_server
LaTeX (unstable preview) ltex
LaTeX texlab
Lua sumneko_lua
OCaml ocamlls
PHP intelephense
PHP phpactor
Prisma prismals
Puppet puppet
PureScript purescriptls
Python pylsp
Python pyright
ReScript rescriptls
Rome rome
Ruby solargraph
Rust rust_analyzer
SQL sqlls
SQL sqls
Solang Solidity solang
Stylelint stylelint_lsp
Svelte svelte
Tailwind CSS tailwindcss
Terraform terraformls
Terraform (docs) tflint
TypeScript (docs) tsserver
VimL vimls
Vue volar
Vue vuels
XML lemminx
YAML yamlls
Zig zls

Custom servers

You can create your own installers by using the same APIs nvim-lsp-installer itself uses. Refer to CUSTOM_SERVERS.md for more information.

Logo

Illustrations in the logo are derived from @Kaligule's "Robots" collection.

Roadmap

  • Command (and corresponding Lua API) to update outdated servers (e.g., :LspUpdate {server})
  • More helpful metadata displayed in the UI window
  • Cross-platform CI for all server installers

Default configuration

local DEFAULT_SETTINGS = {
    ui = {
        icons = {
            -- The list icon to use for installed servers.
            server_installed = "",
            -- The list icon to use for servers that are pending installation.
            server_pending = "",
            -- The list icon to use for servers that are not installed.
            server_uninstalled = "",
        },
        keymaps = {
            -- Keymap to expand a server in the UI
            toggle_server_expand = "<CR>",
            -- Keymap to install a server
            install_server = "i",
            -- Keymap to reinstall/update a server
            update_server = "u",
            -- Keymap to uninstall a server
            uninstall_server = "X",
        },
    },

    -- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when
    -- debugging issues with server installations.
    log_level = vim.log.levels.INFO,

    -- Whether to allow LSP servers to share the same installation directory. For some servers, this effectively causes
    -- more than one server to be installed (and uninstalled) when executing `:LspInstall` and `:LspUninstall`. For
    -- example, installing `cssls` will also install both `jsonls` and `html` (and the other ways around), as these all
    -- share the same underlying package.
    allow_federated_servers = true,

    -- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further
    -- servers that are requested to be installed will be put in a queue.
    max_concurrent_installers = 4,
}

nvim-lsp-installer's People

Contributors

alex-popov-tech avatar aspeddro avatar connorlay avatar gabrielbdd avatar ivano9 avatar kylo252 avatar lctrs avatar mystilleef avatar tamago324 avatar teodev1611 avatar tkmpypy avatar williamboman avatar xdoardo avatar xntebli avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.