aboutsummaryrefslogtreecommitdiffstats
path: root/CONTRIBUTING.md
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2022-04-16 22:45:14 -0700
committerGitHub <noreply@github.com>2022-04-16 22:45:14 -0700
commit31be570201581dd23718722d51021dc55255454c (patch)
tree1110fc2acc13c1c4309388c2e6572aad774ea6f1 /CONTRIBUTING.md
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-31be570201581dd23718722d51021dc55255454c.tar
nvim-lspconfig-31be570201581dd23718722d51021dc55255454c.tar.gz
nvim-lspconfig-31be570201581dd23718722d51021dc55255454c.tar.bz2
nvim-lspconfig-31be570201581dd23718722d51021dc55255454c.tar.lz
nvim-lspconfig-31be570201581dd23718722d51021dc55255454c.tar.xz
nvim-lspconfig-31be570201581dd23718722d51021dc55255454c.tar.zst
nvim-lspconfig-31be570201581dd23718722d51021dc55255454c.zip
docs: update outdated example in contributing (#1843)
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r--CONTRIBUTING.md59
1 files changed, 43 insertions, 16 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 40f12cc5..7eea3f74 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -44,35 +44,62 @@ Additionally, the following options are often added:
* `init_options`: a table sent during initialization, corresponding to initializationOptions sent in [initializeParams](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#initializeParams) as part of the first request sent from client to server during startup.
* `settings`: a table sent during [`workspace/didChangeConfiguration`](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#didChangeConfigurationParams) shortly after server initialization. This is an undocumented convention for most language servers. There is often some duplication with initOptions.
-A minimal example for adding a new language server is shown below for `pyright`, a python language server included in lspconfig:
+An example for adding a new language server is shown below for `pyright`, a python language server included in lspconfig:
```lua
--- Only `configs` must be required, util is optional if you are using the root resolver functions, which is usually the case.
-local configs = require 'lspconfig.configs'
local util = require 'lspconfig.util'
--- Having server name defined here is the convention, this is often times also the first entry in the `cmd` table.
-local server_name = 'pyright'
+local bin_name = 'pyright-langserver'
+local cmd = { bin_name, '--stdio' }
+
+if vim.fn.has 'win32' == 1 then
+ cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
+end
-configs[server_name] = {
+local root_files = {
+ 'pyproject.toml',
+ 'setup.py',
+ 'setup.cfg',
+ 'requirements.txt',
+ 'Pipfile',
+ 'pyrightconfig.json',
+}
+
+local function organize_imports()
+ local params = {
+ command = 'pyright.organizeimports',
+ arguments = { vim.uri_from_bufnr(0) },
+ }
+ vim.lsp.buf.execute_command(params)
+end
+
+return {
default_config = {
- -- This should be executable on the command line, arguments (such as `--stdio`) are additional entries in the list.
- cmd = { 'pyright-langserver' },
- -- These are the filetypes that the server will either attach or start in response to opening. The user must have a filetype plugin matching the filetype, either via the built-in runtime files or installed via plugin.
+ cmd = cmd,
filetypes = { 'python' },
- -- The root directory that lspconfig uses to determine if it should start a new language server, or attach the current buffer to a previously running language server.
- root_dir = util.find_git_ancestor
- end,
+ root_dir = util.root_pattern(unpack(root_files)),
+ single_file_support = true,
+ settings = {
+ python = {
+ analysis = {
+ autoSearchPaths = true,
+ useLibraryCodeForTypes = true,
+ diagnosticMode = 'workspace',
+ },
+ },
+ },
+ },
+ commands = {
+ PyrightOrganizeImports = {
+ organize_imports,
+ description = 'Organize Imports',
+ },
},
docs = {
- -- The description should include at minimum the link to the github project, and ideally the steps to install the language server.
description = [[
https://github.com/microsoft/pyright
`pyright`, a static type checker and language server for python
-
-`pyright` can be installed via `npm`
-`npm install -g pyright`
]],
},
}