Rename to nvim_lsp and nvim-lsp.

This commit is contained in:
Ashkan Kiani 2019-11-14 01:07:09 -08:00
parent 49ff7949f3
commit 9666b63a70
13 changed files with 102 additions and 102 deletions

View File

@ -72,7 +72,7 @@ Example:
skeleton.texlab.buf_build = buf_build skeleton.texlab.buf_build = buf_build
``` ```
After you create a skeleton, you have to `require 'common_lsp/SERVER_NAME'` in After you create a skeleton, you have to `require 'nvim_lsp/SERVER_NAME'` in
`lua/common_lsp.lua`, and that's it. `lua/nvim_lsp.lua`, and that's it.
Generate docs and you're done. Generate docs and you're done.

View File

@ -14,9 +14,9 @@ things as much as you want in addition to the defaults that this provides.
**CONTRIBUTIONS ARE WELCOME!** **CONTRIBUTIONS ARE WELCOME!**
There's a lot of language servers in the world, and not enough time. See There's a lot of language servers in the world, and not enough time. See
[`lua/common_lsp/texlab.lua`](https://github.com/neovim/nvim-lsp/blob/master/lua/common_lsp/texlab.lua) [`lua/nvim_lsp/texlab.lua`](https://github.com/neovim/nvim-lsp/blob/master/lua/nvim_lsp/texlab.lua)
and and
[`lua/common_lsp/skeleton.lua`](https://github.com/neovim/nvim-lsp/blob/master/lua/common_lsp/skeleton.lua) [`lua/nvim_lsp/skeleton.lua`](https://github.com/neovim/nvim-lsp/blob/master/lua/nvim_lsp/skeleton.lua)
for examples and ask me questions in the [Neovim for examples and ask me questions in the [Neovim
Gitter](https://gitter.im/neovim/neovim) to help me complete configurations for Gitter](https://gitter.im/neovim/neovim) to help me complete configurations for
*all the LSPs!* *all the LSPs!*
@ -26,11 +26,11 @@ implemented from [this excellent list compiled by the coc.nvim
contributors](https://github.com/neoclide/coc.nvim/wiki/Language-servers) or contributors](https://github.com/neoclide/coc.nvim/wiki/Language-servers) or
[this other excellent list from the emacs lsp-mode [this other excellent list from the emacs lsp-mode
contributors](https://github.com/emacs-lsp/lsp-mode#supported-languages) contributors](https://github.com/emacs-lsp/lsp-mode#supported-languages)
and create a new file under `lua/common_lsp/SERVER_NAME.lua`. and create a new file under `lua/nvim_lsp/SERVER_NAME.lua`.
- For a simple server which should only ever have one instance for the entire - For a simple server which should only ever have one instance for the entire
neovim lifetime, I recommend copying `lua/common_lsp/texlab.lua`. neovim lifetime, I recommend copying `lua/nvim_lsp/texlab.lua`.
- For servers which should have a different instance for each project root, I - For servers which should have a different instance for each project root, I
recommend copying `lua/common_lsp/gopls.lua`. recommend copying `lua/nvim_lsp/gopls.lua`.
## Progress ## Progress
@ -55,22 +55,22 @@ In progress:
From vim: From vim:
```vim ```vim
call common_lsp#texlab({}) call nvim_lsp#texlab({})
call common_lsp#gopls({}) call nvim_lsp#gopls({})
" These are still TODO, but will be done. " These are still TODO, but will be done.
call common_lsp#clangd({}) call nvim_lsp#clangd({})
call common_lsp#ccls({}) call nvim_lsp#ccls({})
call common_lsp#tsserver({}) call nvim_lsp#tsserver({})
" Or using a dynamic name. " Or using a dynamic name.
call common_lsp#setup("texlab", {}) call nvim_lsp#setup("texlab", {})
call common_lsp#setup("gopls", {}) call nvim_lsp#setup("gopls", {})
``` ```
From Lua: From Lua:
```lua ```lua
require 'common_lsp'.texlab.setup { require 'nvim_lsp'.texlab.setup {
name = "texlab_fancy"; name = "texlab_fancy";
log_level = vim.lsp.protocol.MessageType.Log; log_level = vim.lsp.protocol.MessageType.Log;
settings = { settings = {
@ -82,15 +82,15 @@ require 'common_lsp'.texlab.setup {
} }
} }
local common_lsp = require 'common_lsp' local nvim_lsp = require 'nvim_lsp'
-- Customize how to find the root_dir -- Customize how to find the root_dir
common_lsp.gopls.setup { nvim_lsp.gopls.setup {
root_dir = common_lsp.util.root_pattern(".git"); root_dir = nvim_lsp.util.root_pattern(".git");
} }
-- Build the current buffer. -- Build the current buffer.
require 'common_lsp'.texlab.buf_build(0) require 'nvim_lsp'.texlab.buf_build(0)
``` ```
``` ```
@ -98,12 +98,12 @@ These are functions to set up servers more easily with some server specific
defaults and more server specific things like commands or different defaults and more server specific things like commands or different
diagnostics. diagnostics.
Servers may define extra functions on the `common_lsp.SERVER` table, e.g. Servers may define extra functions on the `nvim_lsp.SERVER` table, e.g.
`common_lsp.texlab.buf_build({bufnr})`. `nvim_lsp.texlab.buf_build({bufnr})`.
The main setup signature will be: The main setup signature will be:
common_lsp.SERVER.setup({config}) nvim_lsp.SERVER.setup({config})
{config} is the same as |vim.lsp.start_client()|, but with some {config} is the same as |vim.lsp.start_client()|, but with some
additions and changes: additions and changes:
@ -121,14 +121,14 @@ common_lsp.SERVER.setup({config})
If nil is returned, the buffer is skipped. If nil is returned, the buffer is skipped.
See |common_lsp.util.search_ancestors()| and the functions which use it: See |nvim_lsp.util.search_ancestors()| and the functions which use it:
- |common_lsp.util.root_pattern(patterns...)| finds an ancestor which - |nvim_lsp.util.root_pattern(patterns...)| finds an ancestor which
- contains one of the files in `patterns...`. This is equivalent - contains one of the files in `patterns...`. This is equivalent
to coc.nvim's "rootPatterns" to coc.nvim's "rootPatterns"
- More specific utilities: - More specific utilities:
- |common_lsp.util.find_git_root()| - |nvim_lsp.util.find_git_root()|
- |common_lsp.util.find_node_modules_root()| - |nvim_lsp.util.find_node_modules_root()|
- |common_lsp.util.find_package_json_root()| - |nvim_lsp.util.find_package_json_root()|
{name} {name}
Defaults to the server's name. Defaults to the server's name.
@ -174,8 +174,8 @@ as compile_commands.json or, for simpler projects, a compile_flags.txt.
common_lsp.clangd.setup({config}) nvim_lsp.clangd.setup({config})
common_lsp#setup("clangd", {config}) nvim_lsp#setup("clangd", {config})
``` ```
Default Values: Default Values:
@ -195,8 +195,8 @@ A completion engine built from scratch for (la)tex.
common_lsp.texlab.setup({config}) nvim_lsp.texlab.setup({config})
common_lsp#setup("texlab", {config}) nvim_lsp#setup("texlab", {config})
``` ```
Commands: Commands:
@ -225,8 +225,8 @@ Google's lsp server for golang.
common_lsp.gopls.setup({config}) nvim_lsp.gopls.setup({config})
common_lsp#setup("gopls", {config}) nvim_lsp#setup("gopls", {config})
``` ```
Default Values: Default Values:

View File

@ -14,9 +14,9 @@ things as much as you want in addition to the defaults that this provides.
**CONTRIBUTIONS ARE WELCOME!** **CONTRIBUTIONS ARE WELCOME!**
There's a lot of language servers in the world, and not enough time. See There's a lot of language servers in the world, and not enough time. See
[`lua/common_lsp/texlab.lua`](https://github.com/norcalli/nvim-common-lsp/blob/master/lua/common_lsp/texlab.lua) [`lua/nvim_lsp/texlab.lua`](https://github.com/neovim/nvim-lsp/blob/master/lua/nvim_lsp/texlab.lua)
and and
[`lua/common_lsp/skeleton.lua`](https://github.com/norcalli/nvim-common-lsp/blob/master/lua/common_lsp/skeleton.lua) [`lua/nvim_lsp/skeleton.lua`](https://github.com/neovim/nvim-lsp/blob/master/lua/nvim_lsp/skeleton.lua)
for examples and ask me questions in the [Neovim for examples and ask me questions in the [Neovim
Gitter](https://gitter.im/neovim/neovim) to help me complete configurations for Gitter](https://gitter.im/neovim/neovim) to help me complete configurations for
*all the LSPs!* *all the LSPs!*
@ -26,17 +26,17 @@ implemented from [this excellent list compiled by the coc.nvim
contributors](https://github.com/neoclide/coc.nvim/wiki/Language-servers) or contributors](https://github.com/neoclide/coc.nvim/wiki/Language-servers) or
[this other excellent list from the emacs lsp-mode [this other excellent list from the emacs lsp-mode
contributors](https://github.com/emacs-lsp/lsp-mode#supported-languages) contributors](https://github.com/emacs-lsp/lsp-mode#supported-languages)
and create a new file under `lua/common_lsp/SERVER_NAME.lua`. and create a new file under `lua/nvim_lsp/SERVER_NAME.lua`.
- For a simple server which should only ever have one instance for the entire - For a simple server which should only ever have one instance for the entire
neovim lifetime, I recommend copying `lua/common_lsp/texlab.lua`. neovim lifetime, I recommend copying `lua/nvim_lsp/texlab.lua`.
- For servers which should have a different instance for each project root, I - For servers which should have a different instance for each project root, I
recommend copying `lua/common_lsp/gopls.lua`. recommend copying `lua/nvim_lsp/gopls.lua`.
## Progress ## Progress
Implemented: Implemented:
- [gopls](https://github.com/norcalli/nvim-common-lsp#gopls) (has some errors) - [gopls](https://github.com/neovim/nvim-lsp#gopls) (has some errors)
- [texlab](https://github.com/norcalli/nvim-common-lsp#texlab) - [texlab](https://github.com/neovim/nvim-lsp#texlab)
Planned servers to implement (by me, but contributions welcome anyway): Planned servers to implement (by me, but contributions welcome anyway):
- [clangd](https://clang.llvm.org/extra/clangd/Installation.html) - [clangd](https://clang.llvm.org/extra/clangd/Installation.html)
@ -49,28 +49,28 @@ In progress:
## Install ## Install
`Plug 'norcalli/nvim-common-lsp'` `Plug 'neovim/nvim-lsp'`
## Use ## Use
From vim: From vim:
```vim ```vim
call common_lsp#texlab({}) call nvim_lsp#texlab({})
call common_lsp#gopls({}) call nvim_lsp#gopls({})
" These are still TODO, but will be done. " These are still TODO, but will be done.
call common_lsp#clangd({}) call nvim_lsp#clangd({})
call common_lsp#ccls({}) call nvim_lsp#ccls({})
call common_lsp#tsserver({}) call nvim_lsp#tsserver({})
" Or using a dynamic name. " Or using a dynamic name.
call common_lsp#setup("texlab", {}) call nvim_lsp#setup("texlab", {})
call common_lsp#setup("gopls", {}) call nvim_lsp#setup("gopls", {})
``` ```
From Lua: From Lua:
```lua ```lua
require 'common_lsp'.texlab.setup { require 'nvim_lsp'.texlab.setup {
name = "texlab_fancy"; name = "texlab_fancy";
log_level = vim.lsp.protocol.MessageType.Log; log_level = vim.lsp.protocol.MessageType.Log;
settings = { settings = {
@ -82,15 +82,15 @@ require 'common_lsp'.texlab.setup {
} }
} }
local common_lsp = require 'common_lsp' local nvim_lsp = require 'nvim_lsp'
-- Customize how to find the root_dir -- Customize how to find the root_dir
common_lsp.gopls.setup { nvim_lsp.gopls.setup {
root_dir = common_lsp.util.root_pattern(".git"); root_dir = nvim_lsp.util.root_pattern(".git");
} }
-- Build the current buffer. -- Build the current buffer.
require 'common_lsp'.texlab.buf_build(0) require 'nvim_lsp'.texlab.buf_build(0)
``` ```
``` ```
@ -98,12 +98,12 @@ These are functions to set up servers more easily with some server specific
defaults and more server specific things like commands or different defaults and more server specific things like commands or different
diagnostics. diagnostics.
Servers may define extra functions on the `common_lsp.SERVER` table, e.g. Servers may define extra functions on the `nvim_lsp.SERVER` table, e.g.
`common_lsp.texlab.buf_build({bufnr})`. `nvim_lsp.texlab.buf_build({bufnr})`.
The main setup signature will be: The main setup signature will be:
common_lsp.SERVER.setup({config}) nvim_lsp.SERVER.setup({config})
{config} is the same as |vim.lsp.start_client()|, but with some {config} is the same as |vim.lsp.start_client()|, but with some
additions and changes: additions and changes:
@ -121,14 +121,14 @@ common_lsp.SERVER.setup({config})
If nil is returned, the buffer is skipped. If nil is returned, the buffer is skipped.
See |common_lsp.util.search_ancestors()| and the functions which use it: See |nvim_lsp.util.search_ancestors()| and the functions which use it:
- |common_lsp.util.root_pattern(patterns...)| finds an ancestor which - |nvim_lsp.util.root_pattern(patterns...)| finds an ancestor which
- contains one of the files in `patterns...`. This is equivalent - contains one of the files in `patterns...`. This is equivalent
to coc.nvim's "rootPatterns" to coc.nvim's "rootPatterns"
- More specific utilities: - More specific utilities:
- |common_lsp.util.find_git_root()| - |nvim_lsp.util.find_git_root()|
- |common_lsp.util.find_node_modules_root()| - |nvim_lsp.util.find_node_modules_root()|
- |common_lsp.util.find_package_json_root()| - |nvim_lsp.util.find_package_json_root()|
{name} {name}
Defaults to the server's name. Defaults to the server's name.

View File

@ -1,12 +0,0 @@
function! common_lsp#setup(name, config)
return luaeval("require'common_lsp'[_A[1]].setup(_A[2])", [a:name, a:config])
endfunction
" function! common_lsp#texlab(config)
" call common_lsp#setup("texlab", a:config)
" endfunction
" function! common_lsp#gopls(config)
" call common_lsp#setup("gopls", a:config)
" endfunction

12
autoload/nvim_lsp.vim Normal file
View File

@ -0,0 +1,12 @@
function! nvim_lsp#setup(name, config)
return luaeval("require'nvim_lsp'[_A[1]].setup(_A[2])", [a:name, a:config])
endfunction
" function! nvim_lsp#texlab(config)
" call nvim_lsp#setup("texlab", a:config)
" endfunction
" function! nvim_lsp#gopls(config)
" call nvim_lsp#setup("gopls", a:config)
" endfunction

View File

@ -1,16 +0,0 @@
local skeleton = require 'common_lsp/skeleton'
require 'common_lsp/gopls'
require 'common_lsp/texlab'
require 'common_lsp/clangd'
local M = {
util = require 'common_lsp/util';
}
local mt = {}
function mt:__index(k)
return skeleton[k]
end
return setmetatable(M, mt)
-- vim:et ts=2 sw=2

16
lua/nvim_lsp.lua Normal file
View File

@ -0,0 +1,16 @@
local skeleton = require 'nvim_lsp/skeleton'
require 'nvim_lsp/gopls'
require 'nvim_lsp/texlab'
require 'nvim_lsp/clangd'
local M = {
util = require 'nvim_lsp/util';
}
local mt = {}
function mt:__index(k)
return skeleton[k]
end
return setmetatable(M, mt)
-- vim:et ts=2 sw=2

View File

@ -1,5 +1,5 @@
local skeleton = require 'common_lsp/skeleton' local skeleton = require 'nvim_lsp/skeleton'
local util = require 'common_lsp/util' local util = require 'nvim_lsp/util'
local lsp = vim.lsp local lsp = vim.lsp
local default_capabilities = lsp.protocol.make_client_capabilities() local default_capabilities = lsp.protocol.make_client_capabilities()

View File

@ -1,5 +1,5 @@
local skeleton = require 'common_lsp/skeleton' local skeleton = require 'nvim_lsp/skeleton'
local util = require 'common_lsp/util' local util = require 'nvim_lsp/util'
local lsp = vim.lsp local lsp = vim.lsp
skeleton.gopls = { skeleton.gopls = {

View File

@ -1,4 +1,4 @@
local util = require 'common_lsp/util' local util = require 'nvim_lsp/util'
local api, validate, lsp = vim.api, vim.validate, vim.lsp local api, validate, lsp = vim.api, vim.validate, vim.lsp
local tbl_extend = vim.tbl_extend local tbl_extend = vim.tbl_extend
@ -76,7 +76,7 @@ function skeleton.__newindex(t, template_name, template)
trigger = "BufReadPost *" trigger = "BufReadPost *"
end end
api.nvim_command(string.format( api.nvim_command(string.format(
"autocmd %s lua require'common_lsp'[%q].manager.try_add()" "autocmd %s lua require'nvim_lsp'[%q].manager.try_add()"
, trigger , trigger
, config.name , config.name
)) ))
@ -118,7 +118,7 @@ function skeleton.__newindex(t, template_name, template)
M._setup_buffer(client.id) M._setup_buffer(client.id)
else else
api.nvim_command(string.format( api.nvim_command(string.format(
"autocmd BufEnter <buffer=%d> ++once lua require'common_lsp'[%q]._setup_buffer(%d)" "autocmd BufEnter <buffer=%d> ++once lua require'nvim_lsp'[%q]._setup_buffer(%d)"
, template_name , template_name
, bufnr , bufnr
, client.id , client.id

View File

@ -1,5 +1,5 @@
local skeleton = require 'common_lsp/skeleton' local skeleton = require 'nvim_lsp/skeleton'
local util = require 'common_lsp/util' local util = require 'nvim_lsp/util'
local lsp = vim.lsp local lsp = vim.lsp
local cwd = vim.loop.cwd() local cwd = vim.loop.cwd()

View File

@ -84,7 +84,7 @@ function M.create_module_commands(module_name, commands)
table.insert(parts, command_name) table.insert(parts, command_name)
-- The command definition. -- The command definition.
table.insert(parts, table.insert(parts,
string.format("lua require'common_lsp'[%q].commands[%q][1]()", module_name, command_name)) string.format("lua require'nvim_lsp'[%q].commands[%q][1]()", module_name, command_name))
api.nvim_command(table.concat(parts, " ")) api.nvim_command(table.concat(parts, " "))
end end
end end

View File

@ -1,4 +1,4 @@
local skeleton = require 'common_lsp/skeleton' local skeleton = require 'nvim_lsp/skeleton'
local inspect = vim.inspect local inspect = vim.inspect
local function filter(...) local function filter(...)
@ -91,8 +91,8 @@ for k, v in pairs(skeleton) do
## {{template_name}} ## {{template_name}}
{{preamble}} {{preamble}}
common_lsp.{{template_name}}.setup({config}) nvim_lsp.{{template_name}}.setup({config})
common_lsp#setup("{{template_name}}", {config}) nvim_lsp#setup("{{template_name}}", {config})
``` ```
{{body}} {{body}}