Skip to content

Commit 53d9888

Browse files
committed
feat: support vim.lsp.config
1 parent de68846 commit 53d9888

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,12 @@ To modify the default configuration, set `vim.g.haskell_tools`.
331331

332332
```lua
333333
vim.g.haskell_tools = {
334-
---@type ToolsOpts
334+
---@type haskell-tools.tools.Opts
335335
tools = {
336336
-- ...
337337
},
338-
---@type HaskellLspClientOpts
338+
---@type haskell-tools.lsp.ClientOpts
339+
---You can also configure these via `:h vim.lsp.config`, with the "hls" key.
339340
hls = {
340341
---@param client number The LSP client ID.
341342
---@param bufnr number The buffer number
@@ -345,7 +346,7 @@ vim.g.haskell_tools = {
345346
end,
346347
-- ...
347348
},
348-
---@type HTDapOpts
349+
---@type haskell-tools.dap.Opts
349350
dap = {
350351
-- ...
351352
},

doc/haskell-tools.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ haskell-tools.Opts *haskell-tools.Opts*
7171
haskell-tools module options.
7272
{hls?} (haskell-tools.lsp.ClientOpts)
7373
haskell-language-server client options.
74+
You can also configure these via |vim.lsp.config|, with the `"hls"` key.
7475
{dap?} (haskell-tools.dap.Opts)
7576
debug adapter config for nvim-dap.
7677

@@ -236,7 +237,7 @@ haskell-tools.lsp.ClientOpts *haskell-tools.lsp.ClientOpts*
236237
LSP client capabilities.
237238
{settings?} (fun(project_root:string|nil):table|table)
238239
The haskell-language-server settings or a function that creates them.
239-
To view the default settings, run `haskell-language-server generate-default-config`.
240+
To view the default settings, run `haskell-language-server generate-default-config`.
240241
{default_settings?} (table)
241242
The default haskell-language-server settings that will be used if no settings are specified or detected.
242243
{logfile?} (string)

lua/haskell-tools/config/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ vim.g.haskell_tools = vim.g.haskell_tools
4141
---@field tools? haskell-tools.tools.Opts
4242
---
4343
---haskell-language-server client options.
44+
---You can also configure these via |vim.lsp.config|, with the `"hls"` key.
4445
---@field hls? haskell-tools.lsp.ClientOpts
4546
---
4647
---debug adapter config for nvim-dap.
@@ -187,7 +188,7 @@ vim.g.haskell_tools = vim.g.haskell_tools
187188
---@field capabilities? lsp.ClientCapabilities
188189
---
189190
---The haskell-language-server settings or a function that creates them.
190-
--- To view the default settings, run `haskell-language-server generate-default-config`.
191+
---To view the default settings, run `haskell-language-server generate-default-config`.
191192
---@field settings? (fun(project_root:string|nil):table) | table
192193
---
193194
---The default haskell-language-server settings that will be used if no settings are specified or detected.

lua/haskell-tools/lsp/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,11 @@ Hls.start = function(bufnr)
117117
return
118118
end
119119
local HtProjectHelpers = require('haskell-tools.project.helpers')
120+
local LspHelpers = require('haskell-tools.lsp.helpers')
120121
local is_cabal = HtProjectHelpers.is_cabal_file(bufnr)
121122
local project_root = ht.project.root_dir(file)
122123
local hls_settings = type(hls_opts.settings) == 'function' and hls_opts.settings(project_root) or hls_opts.settings
123-
local LspHelpers = require('haskell-tools.lsp.helpers')
124+
124125
local cmd = LspHelpers.get_hls_cmd()
125126
local hls_bin = cmd[1]
126127
if vim.fn.executable(hls_bin) == 0 then
@@ -170,8 +171,8 @@ Hls.start = function(bufnr)
170171
fix_cabal_client(client)
171172
end,
172173
}
173-
log.debug('LSP start options: lsp_start_opts')
174-
local client_id = vim.lsp.start(lsp_start_opts)
174+
local client_config = vim.tbl_deep_extend('force', {}, lsp_start_opts, vim.lsp.config['hls'] or {})
175+
local client_id = vim.lsp.start(client_config)
175176
return client_id
176177
end
177178

0 commit comments

Comments
 (0)