==============================================================================
Table of Contents                                       *haskell-tools.contents*

Introduction ··························································· |intro|
The haskell-tools module ······································· |haskell-tools|
plugin configuration ···································· |haskell-tools.config|
haskell-language-server LSP client tools ··················· |haskell-tools.lsp|
haskell-tools nvim-dap setup ······························· |haskell-tools.dap|
haskell-tools Hoogle search ····························· |haskell-tools.hoogle|
haskell-tools GHCi REPL module ···························· |haskell-tools.repl|
haskell-tools Project module ··························· |haskell-tools.project|
haskell-tools fast-tags module ···························· |haskell-tools.tags|
haskell-tools Logging ······································ |haskell-tools.log|

==============================================================================
Introduction                                                             *intro*

This plugin automatically configures the `haskell-language-server` builtin LSP client
and integrates with other haskell tools.

WARNING:
Do not call the `lspconfig.hls` setup or set up the lsp manually,
as doing so may cause conflicts.

NOTE: This plugin is a filetype plugin.
There is no need to call a `setup` function.

==============================================================================
The haskell-tools module                                         *haskell-tools*

Entry-point into this plugin's public API.

HaskellTools                                                      *HaskellTools*


==============================================================================
plugin configuration                                      *haskell-tools.config*

To configure haskell-tools.nvim, set the variable `vim.g.haskell_tools`,
which is a `HTOpts` table, in your neovim configuration.

Example:
>
---@type HTOpts
vim.g.haskell_tools = {
   ---@type ToolsOpts
   tools = {
     -- ...
   },
   ---@type HaskellLspClientOpts
   hls = {
     on_attach = function(client, bufnr)
       -- Set keybindings, etc. here.
     end,
     -- ...
   },
   ---@type HTDapOpts
   dap = {
     -- ...
   },
 }
<

Note: `vim.g.haskell_tools` can also be a function that returns a 'HTOpts' table.


HTOpts                                                                  *HTOpts*

    Fields: ~
        {tools?}  (ToolsOpts)             haskell-tools module options.
        {hls?}    (HaskellLspClientOpts)  haskell-language-server client options.
        {dap?}    (HTDapOpts)             debug adapter config for nvim-dap.


ToolsOpts                                                            *ToolsOpts*

    Fields: ~
        {codeLens?}    (CodeLensOpts)    LSP codeLens options.
        {hoogle?}      (HoogleOpts)      Hoogle type signature search options.
        {hover?}       (HoverOpts)       LSP hover options.
        {definition?}  (DefinitionOpts)  LSP go-to-definition options.
        {repl?}        (ReplOpts)        GHCi repl options.
        {tags?}        (FastTagsOpts)    fast-tags module options.
        {log?}         (HTLogOpts)       haskell-tools logger options.


CodeLensOpts                                                      *CodeLensOpts*

    Fields: ~
        {autoRefresh?}  (fun():boolean|boolean)  (default: `true`) Whether to auto-refresh code-lenses.


HoogleOpts                                                          *HoogleOpts*

    Fields: ~
        {mode?}  (HoogleMode)  Use a telescope with a local hoogle installation or a web backend, or use the browser for hoogle signature search?


HoogleMode                                                          *HoogleMode*

    Type: ~
        "auto"|"telescope-local"|"telescope-web"|"browser"


HoverOpts                                                            *HoverOpts*

    Fields: ~
        {enable?}            (fun():boolean|boolean)  (default: `true`) Whether to enable haskell-tools hover.
        {border?}            (string[][])             The hover window's border. Set to `nil` to disable.
        {stylize_markdown?}  (boolean)                (default: `false`) The builtin LSP client's default behaviour is to stylize markdown. Setting this option to false sets the file type to markdown and enables treesitter syntax highligting for Haskell snippets if nvim-treesitter is installed.
        {auto_focus?}        (boolean)                (default: `false`) Whether to automatically switch to the hover window.


DefinitionOpts                                                  *DefinitionOpts*

    Fields: ~
        {hoogle_signature_fallback?}  (fun():boolean|boolean)  (default: `false`) Configure `vim.lsp.definition` to fall back to hoogle search (does not affect `vim.lsp.tagfunc`).


ReplOpts                                                              *ReplOpts*

    Fields: ~
        {handler?}     (fun():ReplHandler|ReplHandler)    `'builtin'`: Use the simple builtin repl. `'toggleterm'`: Use akinsho/toggleterm.nvim.
        {prefer?}      (fun():repl_backend|repl_backend)  Prefer cabal or stack when both stack and cabal project files are present?
        {builtin?}     (BuiltinReplOpts)                  Configuration for the builtin repl.
        {auto_focus?}  (boolean)                          Whether to auto-focus the repl on toggle or send. If unset, the handler decides.


ReplHandler                                                        *ReplHandler*

    Type: ~
        "builtin"|"toggleterm"


repl_backend                                                      *repl_backend*

    Type: ~
        "cabal"|"stack"


BuiltinReplOpts                                                *BuiltinReplOpts*

    Fields: ~
        {create_repl_window?}  (fun(view:ReplView):fun(mk_repl_cmd:mk_repl_cmd_fun))


ReplView                                                              *ReplView*

    Fields: ~
        {create_repl_split?}    (fun(opts:ReplViewOpts):mk_repl_cmd_fun)  Create the REPL in a horizontally split window.
        {create_repl_vsplit?}   (fun(opts:ReplViewOpts):mk_repl_cmd_fun)  Create the REPL in a vertically split window.
        {create_repl_tabnew?}   (fun(opts:ReplViewOpts):mk_repl_cmd_fun)  Create the REPL in a new tab.
        {create_repl_cur_win?}  (fun(opts:ReplViewOpts):mk_repl_cmd_fun)  Create the REPL in the current window.


ReplViewOpts                                                      *ReplViewOpts*

    Fields: ~
        {delete_buffer_on_exit?}  (boolean)              Whether to delete the buffer when the Repl quits.
        {size?}                   (fun():number|number)  The size of the window or a function that determines it.


mk_repl_cmd_fun                                                *mk_repl_cmd_fun*

    Type: ~
        fun():string[]|nil


FastTagsOpts                                                      *FastTagsOpts*

    Fields: ~
        {enable?}  (boolean|fun():boolean)


HTLogOpts                                                            *HTLogOpts*

    Fields: ~
        {level?}  (number|string)  The log level.

    See: ~
        |vim.log.levels|


HaskellLspClientOpts                                      *HaskellLspClientOpts*

    Fields: ~
        {auto_attach?}       (fun():boolean|boolean)                            Whether to automatically attach the LSP client. Defaults to `true` if the haskell-language-server executable is found.
        {debug?}             (boolean)                                          Whether to enable haskell-language-server debug logging.
        {on_attach?}         (fun(client:number,bufnr:number,ht:HaskellTools))  Callback that is invoked when the client attaches to a buffer.
        {cmd?}               (fun():string[]|string[])                          The command to start haskell-language-server with.
        {capabilities?}      (lsp.ClientCapabilities)                           LSP client capabilities.
        {settings?}          (fun(project_root:string|nil):table|table)         The haskell-language-server settings or a function that creates them. To view the default settings, run `haskell-language-server generate-default-config`.
        {default_settings?}  (table)                                            The default haskell-language-server settings that will be used if no settings are specified or detected.
        {logfile?}           (string)                                           The path to the haskell-language-server log file.


 To print all options that are available for your haskell-language-server version, run `haskell-language-server-wrapper generate-default-config`
See: https://haskell-language-server.readthedocs.io/en/latest/configuration.html.

HTDapOpts                                                            *HTDapOpts*

    Fields: ~
        {cmd?}            (string[])                     The command to start the debug adapter server with.
        {logFile?}        (string)                       Log file path for detected configurations.
        {logLevel?}       (HaskellDebugAdapterLogLevel)  The log level for detected configurations.
        {auto_discover?}  (boolean|AddDapConfigOpts)     Set to `false` to disable auto-discovery of launch configurations. `true` uses the default configurations options`.


HaskellDebugAdapterLogLevel                        *HaskellDebugAdapterLogLevel*

    Type: ~
        "Debug"|"Info"|"Warning"|"Error"


==============================================================================
haskell-language-server LSP client tools                     *haskell-tools.lsp*

 The following commands are available:

 * `:HlsStart` - Start the LSP client.
 * `:HlsStop` - Stop the LSP client.
 * `:HlsRestart` - Restart the LSP client.
 * `:HlsEvalAll` - Evaluate all code snippets in comments.

LoadHlsSettingsOpts                                        *LoadHlsSettingsOpts*

    Fields: ~
        {settings_file_pattern}  (string|nil)  File name or pattern to search for. Defaults to 'hls.json'


HlsTools                                                              *HlsTools*


                                                    *HlsTools.load_hls_settings*
HlsTools.load_hls_settings({project_root}, {opts})
    Search the project root for a haskell-language-server settings JSON file and load it to a Lua table.
    Falls back to the `hls.default_settings` if no file is found or file cannot be read or decoded.

    Parameters: ~
        {project_root}  (string|nil)               The project root
        {opts}          (LoadHlsSettingsOpts|nil)

    Returns: ~
        (table)  hls_settings

    See: ~
        |https://haskell-language-server.readthedocs.io/en/latest/configuration.html|


HlsTools.start({bufnr})                                         *HlsTools.start*
    Start or attach the LSP client.
    Fails silently if the buffer's filetype is not one of the filetypes specified in the config.

    Parameters: ~
        {bufnr}  (number|nil)  The buffer number (optional), defaults to the current buffer

    Returns: ~
        (number|nil)  The LSP client ID


HlsTools.stop({bufnr})                                           *HlsTools.stop*
    Stop the LSP client.

    Parameters: ~
        {bufnr}  (number|nil)  The buffer number (optional), defaults to the current buffer

    Returns: ~
        (table[])  A list of clients that will be stopped


HlsTools.restart({bufnr})                                     *HlsTools.restart*
    Restart the LSP client.
    Fails silently if the buffer's filetype is not one of the filetypes specified in the config.

    Parameters: ~
        {bufnr}  (number|nil)  The buffer number (optional), defaults to the current buffer

    Returns: ~
        (number|nil)  The LSP client ID after restart


HlsTools.buf_eval_all({bufnr})                           *HlsTools.buf_eval_all*
    Evaluate all code snippets in comments.

    Parameters: ~
        {bufnr}  (number|nil)  Defaults to the current buffer.

    Returns: ~
        (nil)


==============================================================================
haskell-tools nvim-dap setup                                 *haskell-tools.dap*

HsDapLaunchConfiguration                              *HsDapLaunchConfiguration*


HsDapTools                                                          *HsDapTools*


AddDapConfigOpts                                              *AddDapConfigOpts*


                                            *HsDapTools.discover_configurations*
HsDapTools.discover_configurations({bufnr}, {opts})
    Discover nvim-dap launch configurations for haskell-debug-adapter.

    Parameters: ~
        {bufnr}  (number|nil)            The buffer number
        {opts}   (AddDapConfigOpts|nil)

    Returns: ~
        (nil)


==============================================================================
haskell-tools Hoogle search                               *haskell-tools.hoogle*

HoogleTools                                                        *HoogleTools*


HoogleTools.hoogle_signature({options})           *HoogleTools.hoogle_signature*

    Parameters: ~
        {options}  (table<string,any>|nil)  Includes the `search_term` and options to pass to the telescope picker (if available)

    Returns: ~
        (nil)


==============================================================================
haskell-tools GHCi REPL module                              *haskell-tools.repl*

 The following commands are available:

 * `:HtReplToggle` - Toggle a GHCi repl.
 * `:HtReplQuit` - Quit the current repl.
 * `:HtReplLoad` - Load a Haskell file into the repl.
 * `:HtReplReload` - Reload the current repl.

HsReplTools                                                        *HsReplTools*


HsReplTools.buf_mk_repl_cmd()                      *HsReplTools.buf_mk_repl_cmd*
    Create the command to create a repl for the current buffer.

    Returns: ~
        (table|nil)  command


HsReplTools.operator()                                    *HsReplTools.operator*

    See: ~
        |operatorfunc|


HsReplTools.paste({reg})                                     *HsReplTools.paste*
    Paste from register `reg` to the REPL

    Parameters: ~
        {reg}  (string|nil)  register (defaults to '"')


HsReplTools.paste_type({reg})                           *HsReplTools.paste_type*
    Query the REPL for the type of register `reg`

    Parameters: ~
        {reg}  (string|nil)  register (defaults to '"')


HsReplTools.cword_type()                                *HsReplTools.cword_type*
    Query the REPL for the type of word under the cursor


HsReplTools.paste_info({reg})                           *HsReplTools.paste_info*
    Query the REPL for info on register `reg`

    Parameters: ~
        {reg}  (string|nil)  register (defaults to '"')


HsReplTools.cword_info()                                *HsReplTools.cword_info*
    Query the REPL for the type of word under the cursor


HsReplTools.load_file({filepath})                        *HsReplTools.load_file*
    Load a file into the REPL

    Parameters: ~
        {filepath}  (string)  The absolute file path


HsReplTools.reload()                                        *HsReplTools.reload*
    Reload the repl


==============================================================================
haskell-tools Project module                             *haskell-tools.project*

 The following commands are available:

 * `:HsProjectFile` - Open the project file for the current buffer (cabal.project or stack.yaml).
 * `:HsPackageYaml` - Open the package.yaml file for the current buffer.
 * `:HsPackageCabal` - Open the *.cabal file for the current buffer.

HsProjectTools                                                  *HsProjectTools*


HsProjectTools.root_dir({project_file})                *HsProjectTools.root_dir*
    Get the project's root directory

    Parameters: ~
        {project_file}  (string)  The path to a project file

    Returns: ~
        (string|nil)


HsProjectTools.open_package_yaml()            *HsProjectTools.open_package_yaml*
    Open the package.yaml of the package containing the current buffer.

    Returns: ~
        (nil)


HsProjectTools.open_package_cabal()          *HsProjectTools.open_package_cabal*
    Open the *.cabal file of the package containing the current buffer.

    Returns: ~
        (nil)


HsProjectTools.open_project_file()            *HsProjectTools.open_project_file*
    Open the current buffer's project file (cabal.project or stack.yaml).

    Returns: ~
        (nil)


==============================================================================
haskell-tools fast-tags module                              *haskell-tools.tags*

GenerateProjectTagsOpts                                *GenerateProjectTagsOpts*

    Fields: ~
        {refresh}  (boolean)  Whether to refresh the tags if they have already been generated


FastTagsTools                                                    *FastTagsTools*
     for the project (default: true)


                                           *FastTagsTools.generate_project_tags*
FastTagsTools.generate_project_tags({path}, {opts})
    Generates tags for the current project

    Parameters: ~
        {path}  (string|nil)                   File path
        {opts}  (GenerateProjectTagsOpts|nil)  Options


                                           *FastTagsTools.generate_package_tags*
FastTagsTools.generate_package_tags({path})
    Generate tags for the package containing `path`

    Parameters: ~
        {path}  (string|nil)  File path


==============================================================================
haskell-tools Logging                                        *haskell-tools.log*

 The following commands are available:

 * `:HtLog` - Open the haskell-tools.nvim log file.
 * `:HlsLog` - Open the haskell-language-server log file.
 * `:HtSetLogLevel` - Set the haskell-tools.nvim and LSP client log level.

HaskellToolsLog                                                *HaskellToolsLog*


HaskellToolsLog.get_hls_logfile()              *HaskellToolsLog.get_hls_logfile*
    Get the haskell-language-server log file

    Returns: ~
        (string)  filepath


HaskellToolsLog.get_logfile()                      *HaskellToolsLog.get_logfile*
    Get the haskell-tools.nvim log file path.

    Returns: ~
        (string)  filepath


HaskellToolsLog.nvim_open_hls_logfile()  *HaskellToolsLog.nvim_open_hls_logfile*
    Open the haskell-language-server log file

    Returns: ~
        (nil)


HaskellToolsLog.nvim_open_logfile()          *HaskellToolsLog.nvim_open_logfile*
    Open the haskell-tools.nvim log file.

    Returns: ~
        (nil)


HaskellToolsLog.set_level()                          *HaskellToolsLog.set_level*

    Returns: ~
        (nil)

    See: ~
        |vim.log.levels|


vim:tw=78:ts=8:noet:ft=help:norl:
