Skip to content

Commit

Permalink
fix(npm): resolve the command correctly on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kylo252 committed Dec 8, 2021
1 parent 22b21bc commit a2719a8
Show file tree
Hide file tree
Showing 31 changed files with 210 additions and 47 deletions.
24 changes: 16 additions & 8 deletions lua/lspconfig/server_configurations/angularls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ end

local default_probe_dir = get_probe_dir(vim.fn.getcwd())

local bin_name = 'ngserver'
local args = {
'--stdio',
'--tsProbeLocations',
default_probe_dir,
'--ngProbeLocations',
default_probe_dir,
}

local cmd = { bin_name, unpack(args) }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, unpack(args) }
end

return {
default_config = {
cmd = {
'ngserver',
'--stdio',
'--tsProbeLocations',
default_probe_dir,
'--ngProbeLocations',
default_probe_dir,
},
cmd = cmd,
filetypes = { 'typescript', 'html', 'typescriptreact', 'typescript.tsx' },
-- Check for angular.json or .git first since that is the root of the project.
-- Don't check for tsconfig.json or package.json since there are multiple of these
Expand Down
9 changes: 8 additions & 1 deletion lua/lspconfig/server_configurations/ansiblels.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'ansible-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { 'ansible-language-server', '--stdio' },
cmd = cmd,
settings = {
ansible = {
python = {
Expand Down
9 changes: 8 additions & 1 deletion lua/lspconfig/server_configurations/bashls.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'bash-language-server'
local cmd = { bin_name, 'start' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, 'start' }
end

return {
default_config = {
cmd = { 'bash-language-server', 'start' },
cmd = cmd,
cmd_env = {
-- Prevent recursive scanning which will cause issues when opening a file
-- directly in the home directory (e.g. ~/foo.sh).
Expand Down
7 changes: 6 additions & 1 deletion lua/lspconfig/server_configurations/cssls.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'vscode-css-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { bin_name, '--stdio' },
cmd = cmd,
filetypes = { 'css', 'scss', 'less' },
root_dir = util.root_pattern('package.json', '.git'),
single_file_support = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'cucumber-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { 'cucumber-language-server', '--stdio' },
cmd = cmd,
filetypes = { 'cucumber' },
root_dir = util.find_git_ancestor,
},
Expand Down
6 changes: 4 additions & 2 deletions lua/lspconfig/server_configurations/diagnosticls.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'diagnostic-languageserver'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.cmd'
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { bin_name, '--stdio' },
cmd = cmd,
root_dir = util.find_git_ancestor,
single_file_support = true,
filetypes = {},
Expand Down
9 changes: 8 additions & 1 deletion lua/lspconfig/server_configurations/dockerls.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'docker-langserver'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { 'docker-langserver', '--stdio' },
cmd = cmd,
filetypes = { 'dockerfile' },
root_dir = util.root_pattern 'Dockerfile',
single_file_support = true,
Expand Down
9 changes: 8 additions & 1 deletion lua/lspconfig/server_configurations/dotls.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'dot-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { 'dot-language-server', '--stdio' },
cmd = cmd,
filetypes = { 'dot' },
root_dir = util.find_git_ancestor,
single_file_support = true,
Expand Down
7 changes: 6 additions & 1 deletion lua/lspconfig/server_configurations/elmls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ local lsp = vim.lsp
local api = vim.api

local bin_name = 'elm-language-server'
local cmd = { bin_name }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name }
end

local default_capabilities = lsp.protocol.make_client_capabilities()
default_capabilities.offsetEncoding = { 'utf-8', 'utf-16' }
local elm_root_pattern = util.root_pattern 'elm.json'

return {
default_config = {
cmd = { bin_name },
cmd = cmd,
-- TODO(ashkan) if we comment this out, it will allow elmls to operate on elm.json. It seems like it could do that, but no other editor allows it right now.
filetypes = { 'elm' },
root_dir = function(fname)
Expand Down
9 changes: 8 additions & 1 deletion lua/lspconfig/server_configurations/ember.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'ember-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { 'ember-language-server', '--stdio' },
cmd = cmd,
filetypes = { 'handlebars', 'typescript', 'javascript' },
root_dir = util.root_pattern('ember-cli-build.js', '.git'),
},
Expand Down
9 changes: 8 additions & 1 deletion lua/lspconfig/server_configurations/emmet_ls.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'emmet-ls'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { 'emmet-ls', '--stdio' },
cmd = cmd,
filetypes = { 'html', 'css' },
root_dir = util.find_git_ancestor,
},
Expand Down
8 changes: 7 additions & 1 deletion lua/lspconfig/server_configurations/eslint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ local function fix_all(opts)
end

local bin_name = 'vscode-eslint-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { bin_name, '--stdio' },
cmd = cmd,
filetypes = {
'javascript',
'javascriptreact',
Expand Down
9 changes: 8 additions & 1 deletion lua/lspconfig/server_configurations/graphql.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'graphql-lsp'
local cmd = { bin_name, 'server', '-m', 'stream' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, 'server', '-m', 'stream' }
end

return {
default_config = {
cmd = { 'graphql-lsp', 'server', '-m', 'stream' },
cmd = cmd,
filetypes = { 'graphql', 'typescriptreact', 'javascriptreact' },
root_dir = util.root_pattern('.git', '.graphqlrc*', '.graphql.config.*', 'graphql.config.*'),
},
Expand Down
7 changes: 6 additions & 1 deletion lua/lspconfig/server_configurations/html.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'vscode-html-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { bin_name, '--stdio' },
cmd = cmd,
filetypes = { 'html' },
root_dir = util.root_pattern('package.json', '.git'),
single_file_support = true,
Expand Down
9 changes: 8 additions & 1 deletion lua/lspconfig/server_configurations/intelephense.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'intelephense'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { 'intelephense', '--stdio' },
cmd = cmd,
filetypes = { 'php' },
root_dir = function(pattern)
local cwd = vim.loop.cwd()
Expand Down
6 changes: 4 additions & 2 deletions lua/lspconfig/server_configurations/jsonls.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'vscode-json-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.cmd'
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { bin_name, '--stdio' },
cmd = cmd,
filetypes = { 'json' },
init_options = {
provideFormatter = true,
Expand Down
10 changes: 9 additions & 1 deletion lua/lspconfig/server_configurations/lean3ls.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
local util = require 'lspconfig.util'

local bin_name = 'lean-language-server'
local args = { '--stdio', '--', '-M', '4096', '-T', '100000' }
local cmd = { bin_name, unpack(args) }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, unpack(args) }
end

return {
default_config = {
cmd = { 'lean-language-server', '--stdio', '--', '-M', '4096', '-T', '100000' },
cmd = cmd,
filetypes = { 'lean3' },
root_dir = function(fname)
-- check if inside elan stdlib
Expand Down
8 changes: 7 additions & 1 deletion lua/lspconfig/server_configurations/ocamlls.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
local util = require 'lspconfig.util'

local bin_name = 'ocaml-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end
return {
default_config = {
cmd = { 'ocaml-language-server', '--stdio' },
cmd = cmd,
filetypes = { 'ocaml', 'reason' },
root_dir = util.root_pattern('*.opam', 'esy.json', 'package.json'),
},
Expand Down
6 changes: 4 additions & 2 deletions lua/lspconfig/server_configurations/prismals.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'prisma-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.cmd'
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { bin_name, '--stdio' },
cmd = cmd,
filetypes = { 'prisma' },
settings = {
prisma = {
Expand Down
6 changes: 4 additions & 2 deletions lua/lspconfig/server_configurations/purescriptls.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
local util = require 'lspconfig.util'

local bin_name = 'purescript-language-server'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.cmd'
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

return {
default_config = {
cmd = { bin_name, '--stdio' },
cmd = cmd,
filetypes = { 'purescript' },
root_dir = util.root_pattern('bower.json', 'psc-package.json', 'spago.dhall'),
},
Expand Down
6 changes: 4 additions & 2 deletions lua/lspconfig/server_configurations/pyright.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
local util = require 'lspconfig.util'

local bin_name = 'pyright-langserver'
local cmd = { bin_name, '--stdio' }

if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.cmd'
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

local root_files = {
Expand All @@ -24,7 +26,7 @@ end

return {
default_config = {
cmd = { bin_name, '--stdio' },
cmd = cmd,
filetypes = { 'python' },
root_dir = util.root_pattern(unpack(root_files)),
single_file_support = true,
Expand Down
Loading

0 comments on commit a2719a8

Please sign in to comment.