|
@@ -2,7 +2,7 @@ local M = {}
|
|
|
|
|
|
local Log = require "lvim.core.log"
|
|
|
local utils = require "lvim.utils"
|
|
|
-local get_supported_filetypes = require("lvim.lsp.utils").get_supported_filetypes
|
|
|
+local lvim_lsp_utils = require "lvim.lsp.utils"
|
|
|
|
|
|
local ftplugin_dir = lvim.lsp.templates_dir
|
|
|
|
|
@@ -15,48 +15,20 @@ function M.remove_template_files()
|
|
|
end
|
|
|
end
|
|
|
|
|
|
----Checks if a server is ignored by default because of a conflict
|
|
|
----Only TSServer is enabled by default for the javascript-family
|
|
|
----@param server_name string
|
|
|
-function M.is_ignored(server_name, filetypes)
|
|
|
- --TODO: this is easy to be made configurable once stable
|
|
|
- filetypes = filetypes or get_supported_filetypes(server_name)
|
|
|
-
|
|
|
- if vim.tbl_contains(filetypes, "javascript") then
|
|
|
- if server_name == "tsserver" then
|
|
|
- return false
|
|
|
- else
|
|
|
- return true
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- local blacklist = {
|
|
|
- "jedi_language_server",
|
|
|
- "pylsp",
|
|
|
- "sqlls",
|
|
|
- "sqls",
|
|
|
- "angularls",
|
|
|
- "ansiblels",
|
|
|
- }
|
|
|
- return vim.tbl_contains(blacklist, server_name)
|
|
|
-end
|
|
|
-
|
|
|
---Generates an ftplugin file based on the server_name in the selected directory
|
|
|
---@param server_name string name of a valid language server, e.g. pyright, gopls, tsserver, etc.
|
|
|
---@param dir string the full path to the desired directory
|
|
|
function M.generate_ftplugin(server_name, dir)
|
|
|
- -- we need to go through lspconfig to get the corresponding filetypes currently
|
|
|
- local filetypes = get_supported_filetypes(server_name) or {}
|
|
|
- if not filetypes then
|
|
|
+ if vim.tbl_contains(lvim.lsp.override, server_name) then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- if M.is_ignored(server_name, filetypes) then
|
|
|
+ -- we need to go through lspconfig to get the corresponding filetypes currently
|
|
|
+ local filetypes = lvim_lsp_utils.get_supported_filetypes(server_name) or {}
|
|
|
+ if not filetypes then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- -- print("got associated filetypes: " .. vim.inspect(filetypes))
|
|
|
-
|
|
|
for _, filetype in ipairs(filetypes) do
|
|
|
local filename = join_paths(dir, filetype .. ".lua")
|
|
|
local setup_cmd = string.format([[require("lvim.lsp.manager").setup(%q)]], server_name)
|