Skip to content

Commit

Permalink
feat: add types for autocompletion with lua_ls
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Aug 2, 2023
1 parent c483e32 commit 4d960a7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/astrolsp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
-- @copyright 2023
-- @license GNU General Public License v3.0

---@type AstroLSPConfig
return {
--- Configuration table of features provided by AstroLSP
-- @usage features = {
Expand Down
2 changes: 1 addition & 1 deletion lua/astrolsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function M.lsp_opts(server_name)
end

--- Setup and configure AstroLSP
---@param opts table options passed by the user to configure AstroLSP
---@param opts AstroLSPConfig options passed by the user to configure AstroLSP
-- @see astrolsp.config
function M.setup(opts)
M.config = vim.tbl_deep_extend("force", M.config, opts)
Expand Down
32 changes: 32 additions & 0 deletions lua/astrolsp/types.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---@meta

---@class AstroLSPFeatureOpts
---@field autoformat boolean?
---@field codelens boolean?
---@field diagnostics_mode integer?
---@field inlay_hints boolean?
---@field lsp_handlers boolean?
---@field semantic_tokens boolean?

---@class AstroLSPFormatOnSaveOpts
---@field enabled boolean?
---@field allow_filetypes string[]?
---@field ignore_filetypes string[]?

---@class AstroLSPFormatOpts
---@field format_on_save boolean|AstroLSPFormatOnSaveOpts?
---@field disabled string[]?
---@field timeout_ms integer?
---@field filter (fun(client):boolean)?

---@class AstroLSPConfig
---@field features AstroLSPFeatureOpts?
---@field capabilities table?
---@field config lspconfig.options?
---@field diagnostics table?
---@field flags table?
---@field formatting AstroLSPFormatOpts?
---@field handlers table<string|integer,fun(server:string,opts:_.lspconfig.options)|boolean?>?
---@field mappings table<string,table<string,table|boolean>>?
---@field servers string[]?
---@field on_attach fun(client,bufnr)?

1 comment on commit 4d960a7

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.