begin rebuild of config to separate files
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
return {
|
||||
cmd = { 'clangd', '--background-index', '--clang-tidy', '--completion-style=detailed' },
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
-- The language servers this config knows about.
|
||||
--
|
||||
-- [1] lspconfig name (see :help lspconfig-all). mason installs it under the same name.
|
||||
-- requires executables that must exist before we install/enable it. This is what keeps one
|
||||
-- config working on a bare server: no java, no jdtls; no python3, no pyright.
|
||||
-- custom true when lua/servers/<name>.lua exists and returns overrides for it.
|
||||
--
|
||||
-- To add a language: add a line here. To tweak one: add lua/servers/<name>.lua and set custom = true.
|
||||
return {
|
||||
{ 'lua_ls', custom = true },
|
||||
{ 'clangd', custom = true },
|
||||
{ 'verible', custom = true },
|
||||
{ 'jdtls', custom = true, requires = { 'java' } },
|
||||
{ 'basedpyright', requires = { 'python3' } },
|
||||
{ 'ruff', custom = true, requires = { 'python3' } },
|
||||
{ 'bashls', requires = { 'npm' } },
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
-- jdtls formats with an Eclipse formatter profile. The project keeps a flat .properties file
|
||||
-- (the one Spotless uses) in config/eclipse-formatter.properties, but jdtls wants an Eclipse
|
||||
-- <profiles> XML export, so convert it to a cached XML file and point jdtls at that.
|
||||
local PROFILE = 'GTCS1332'
|
||||
|
||||
---@param root_dir string|nil
|
||||
---@return string|nil
|
||||
local function formatter_url(root_dir)
|
||||
local props_path = (root_dir or vim.fn.getcwd()) .. '/config/eclipse-formatter.properties'
|
||||
local stat = vim.uv.fs_stat(props_path)
|
||||
if not stat then
|
||||
return nil
|
||||
end
|
||||
|
||||
local xml_path = vim.fn.stdpath 'cache' .. '/jdtls-formatter-' .. vim.fn.sha256(props_path) .. '.xml'
|
||||
local xml_stat = vim.uv.fs_stat(xml_path)
|
||||
if not xml_stat or xml_stat.mtime.sec < stat.mtime.sec then
|
||||
local lines = {
|
||||
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>',
|
||||
'<profiles version="21">',
|
||||
('<profile kind="CodeFormatterProfile" name="%s" version="21">'):format(PROFILE),
|
||||
}
|
||||
for line in io.lines(props_path) do
|
||||
local key, value = line:match '^%s*([^=%s]+)%s*=%s*(.-)%s*$'
|
||||
if key and not key:match '^#' then
|
||||
value = value:gsub('&', '&'):gsub('"', '"'):gsub('<', '<'):gsub('>', '>')
|
||||
table.insert(lines, ('<setting id="%s" value="%s"/>'):format(key, value))
|
||||
end
|
||||
end
|
||||
table.insert(lines, '</profile>')
|
||||
table.insert(lines, '</profiles>')
|
||||
local f = io.open(xml_path, 'w')
|
||||
if f then
|
||||
f:write(table.concat(lines, '\n'))
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
||||
return xml_path
|
||||
end
|
||||
|
||||
return {
|
||||
-- client.settings is snapshotted when the client is constructed, so it has to be changed (and
|
||||
-- pushed to the server) here, after creation, rather than in before_init or config.settings.
|
||||
on_init = function(client)
|
||||
local xml_path = formatter_url(client.root_dir or (client.config and client.config.root_dir))
|
||||
if not xml_path then
|
||||
return
|
||||
end
|
||||
client.settings = vim.tbl_deep_extend('force', client.settings or {}, {
|
||||
java = { format = { enabled = true, settings = { url = xml_path, profile = PROFILE } } },
|
||||
})
|
||||
client:notify('workspace/didChangeConfiguration', { settings = client.settings })
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
return {
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = { callSnippet = 'Replace' },
|
||||
-- diagnostics = { disable = { 'missing-fields' } }, -- uncomment to silence noisy warnings
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
return {
|
||||
-- basedpyright already answers hover requests; keep ruff for diagnostics and fixes only.
|
||||
on_attach = function(client)
|
||||
client.server_capabilities.hoverProvider = false
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
return {
|
||||
cmd = { 'verible-verilog-ls', '--rules_config_search' },
|
||||
}
|
||||
Reference in New Issue
Block a user