Code Monkey home page Code Monkey logo

lspcontainers.nvim's Introduction

lspcontainers.nvim

Neovim plugin for lspcontainers - developed weekly live at The Alt-F4 Stream on Twitch.

IMPORTANT: everything below is a work-in-progress and subject to change at any time

Overview

Provide a simple method for running language servers in Docker containers using neovim/nvim-lspconfig. This plugin expects the same language server names from neovim/nvim-lspconfig. See neovim/nvim-lspconfig/CONFIG.md for a complete list of servers.

Installation

  1. Install latest Docker Engine for your operating system

  2. Install lspconfig and lspcontainers via package manager

  • via packer manager

    use 'neovim/nvim-lspconfig'
    use 'lspcontainers/lspcontainers.nvim'
  • via plug manager

    Plug 'neovim/nvim-lspconfig'
    Plug 'lspcontainers/lspcontainers.nvim'
  1. Setup the language of your choice from Supported LSPs

Advanced Configuration

Additional Languages

You can add the default LSPs through the additional_languages shown below:

NOTE: LspContainers makes no attempt to modify LspConfig. It is up to the end user to correctly configure LspConfig.

require'lspcontainers'.command("lua", {
  additional_languages = {
    lua = "lspcontainers/lua-language-server:1.20.5"
  }
})

Volume Syncing

In some circumstances a language server may need the root_dir path synced with the Docker container. To sync up the volume mount with the lspconfig's root_dir, use on_new_config:

local server = "sumneko_lua"
require'lspconfig'[server].setup{
  on_new_config = function(new_config, new_root_dir)
    new_config.cmd = require'lspcontainers'.command(server, { root_dir = new_root_dir })
  end
}

Supported LSPs

Below is a list of supported language servers for configuration with nvim-lspconfig. Follow a link to find documentation for that config.

bashls

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#bashls

require'lspconfig'.bashls.setup {
  before_init = function(params)
    params.processId = vim.NIL
  end,
  cmd = require'lspcontainers'.command('bashls'),
  root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  ...
}

jsonls

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#jsonls

require'lspconfig'.jsonls.setup {
  before_init = function(params)
    params.processId = vim.NIL
  end,
  cmd = require'lspcontainers'.command('jsonls'),
  root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  ...
}

dockerls

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#dockerls

require'lspconfig'.dockerls.setup {
  before_init = function(params)
    params.processId = vim.NIL
  end,
  cmd = require'lspcontainers'.command('dockerls'),
  root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  ...
}

gopls

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#gopls

require'lspconfig'.gopls.setup {
  cmd = require'lspcontainers'.command('gopls'),
  ...
}

html

require'lspconfig'.gopls.setup {
  before_init = function(params)
    params.processId = vim.NIL
  end,
  cmd = require'lspcontainers'.command('html'),
  root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  ...
}

pylsp

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#pylsp

require'lspconfig'.pylsp.setup {
  cmd = require'lspcontainers'.command('pylsp'),
  ...
}

pyright

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#pyright

require'lspconfig'.pyright.setup {
  before_init = function(params)
    params.processId = vim.NIL
  end,
  cmd = require'lspcontainers'.command('pyright'),
  root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  ...
}

rust_analyzer

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer

require'lspconfig'.rust.setup {
  cmd = require'lspcontainers'.command('rust_analyzer'),
  ...
}

sumneko_lua

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#sumneko_lua

require'lspconfig'.sumneko_lua.setup {
  cmd = require'lspcontainers'.command('sumneko_lua'),
  ...
}

svelte

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#svelte

require'lspconfig'.svelte.setup {
  before_init = function(params)
    params.processId = vim.NIL
  end,
  cmd = require'lspcontainers'.command('svelte'),
  root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  ...
}

terraformls

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#terraformls

require'lspconfig'.terraformls.setup {
  cmd = require'lspcontainers'.command('terraformls'),
  filetypes = { "hcl", "tf", "terraform", "tfvars" },
  ...
}

tsserver

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#tsserver

require'lspconfig'.tsserver.setup {
  before_init = function(params)
    params.processId = vim.NIL
  end,
  cmd = require'lspcontainers'.command('tsserver'),
  root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  ...
}

yamlls

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#yamlls

require'lspconfig'.yamlls.setup {
  before_init = function(params)
    params.processId = vim.NIL
  end,
  cmd = require'lspcontainers'.command('yamlls'),
  root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  ...
}

vuels

https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#vuels

require'lspconfig'.vuels.setup {
  before_init = function(params)
    params.processId = vim.NIL
  end,
  cmd = require'lspcontainers'.command('vuels'),
  root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  ...
}

To contribute to LSPs, please see the lspcontainers/dockerfiles repository.

lspcontainers.nvim's People

Contributors

adrianord avatar dbgeek avatar erikreinert avatar jgero avatar nogweii avatar sharksforarms avatar thismat 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.