| CARVIEW |
static-ls: See README on Github for more information
static-ls ("static language server") reads static project information to provide IDE functionality through the language server protocol. static-ls will not generate this information on its own and instead will rely on the user to generate this information via separate programs
[Skip to Readme]
Modules
[Index] [Quick Jump]
Flags
Manual Flags
| Name | Description | Default |
|---|---|---|
| dev | Defer type errors for development | Disabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- static-ls-0.1.2.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
| Versions [RSS] | 0.1.0, 0.1.2 |
|---|---|
| Change log | CHANGELOG.md |
| Dependencies | array (>=0.5.4 && <0.6), base (>=4.17.0 && <4.19), containers (>=0.6.0 && <0.7), directory (>=1.3.7 && <1.4), errors (>=2.3.0 && <2.4), extra (>=1.7.12 && <1.8), filepath (>=1.4.1 && <1.5), ghc (>=9.4.3 && <9.7), ghc-paths (>=0.1.0 && <0.2), ghcide (>=2.5.0 && <2.6.0), hiedb (>=0.4.2 && <0.5), lsp (>=2.3 && <2.4), lsp-types (>=2.1 && <2.2), mtl (>=2.2.2 && <2.4), optparse-applicative (>=0.17.0.0 && <0.19), parsec (>=3.1.0 && <3.2), sqlite-simple (>=0.4.18 && <0.5), static-ls, template-haskell (>=2.19.0 && <2.21), text (>=2.0.1 && <2.1), transformers (>=0.5.6.2 && <0.7), unliftio-core (>=0.2.1 && <0.3) [details] |
| Tested with | ghc ==9.4.4, ghc ==9.6.3 |
| License | MIT |
| Author | Joseph Sumabat |
| Maintainer | josephrsumabat@gmail.com |
| Uploaded | by suzzr0 at 2024-02-04T09:15:19Z |
| Category | Development |
| Home page | https://github.com/josephsumabat/static-ls#readme |
| Bug tracker | https://github.com/josephsumabat/static-ls/issues |
| Source repo | head: git clone https://github.com/josephsumabat/static-ls |
| Distributions | |
| Executables | static-ls |
| Downloads | 205 total (7 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating |
|
| Status | Docs uploaded by user Build status unknown [no reports yet] |
Readme for static-ls-0.1.2
[back to package description]static-ls
static-ls ("static language server") is a hie files and
hiedb based language server heavily
inspired by halfsp, which reads static
project information to provide IDE functionality through the language server
protocol. static-ls will not generate this information on its own and instead
will rely on the user to generate this information via separate programs
Supported static sources of information currently include:
- hiefiles
- hiedb
The goal of static-ls is to provide a high-speed, low-memory solution for large
projects for which
haskell-language-server
tends to take up too much memory on recompilation.
Haskell-language-server
is recommended if you are not experiencing these issues. static-ls is meant
to work on enterprise size projects where aforementioned constraints can be an
issue. static-ls tends to work better standalone as a code navigation tool
since project edits require re-indexing of hie files but also works reasonably
well for editing with a program such as
ghcid to watch files for compilation and
the -fdefer-type-errors flag.
In the future we plan to use more sources of static information such as interface files to fetch documentation or ghcid's output to fetch diagnostics
Currently only ghc 9.4.4 and 9.6.1 are explicitly supported but I'm happy to add support for other versions of ghc if desired
Usage
-
Compile your project with ide info
-fwrite-ide-infoand-hiedir .hiefilesFor a better UX, the following flags are strongly recommended.
- -fdefer-type-errors - -Werror=deferred-type-errors - -Werror=deferred-out-of-scope-variables - -fno-defer-typed-holesThese flags will allow hie files to be refreshed even if compilation fails to type check and will ensure that type check failures are still thrown as errors.
- If you're using hpack you can add:
to yourghc-options: - -fwrite-ide-info - -hiedir .hiefiles - -fdefer-type-errors - -Werror=deferred-type-errors - -Werror=deferred-out-of-scope-variables - -fno-defer-typed-holespackage.yaml. See this project'spackage.yamlorstatic-ls.cabalfor examples - You may instead add the following to your
cabal.project.localfile:ignore-project: False program-options: ghc-options: -fdefer-type-errors -Werror=deferred-type-errors -Werror=deferred-out-of-scope-variables -fno-defer-typed-holes
- If you're using hpack you can add:
-
Index your project in hiedb running:
hiedb -D .hiedb index .hiefiles --src-base-dir .from your workspace root. If you're on an older version of
hiedbwhere the--src-base-dirargument is not available use:hiedb -D .hiedb index .hiefilesentris also recommended if you want file watching functionality:find -L .hiefiles | entr hiedb -D .hiedb index /_ -
Point your language client to the
static-lsbinary and begin editing! (See Editor Setup for instructions if you're not sure how)
ghcid is recommended to refresh hie files but compiling with cabal build should work as well
Features
static-ls supports the following lsp methods:
textDocument/references- Note that find references only works on top level definitions and can be slow for functions which are used frequently

textDocument/hover- Provides type information and definition location on hover

textDocument/definition- Works on both local and top level definitions

Limitations
- Must be compiled on the same version of ghc as the project
- You will need to re-index your hie files once you edit your project
Editor setup
Instructions for editor setup
neovim - coc.nvim
call :CocConfig and copy the following in:
{
"languageserver": {
"static-ls": {
"command": "static-ls",
"rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"],
"filetypes": ["haskell"]
},
},
}
Visual Studio Code
-
Install the Haskell language extension

-
Open the extension settings

-
Scroll down until you see "Server Executable Path" and set the path to the path of your
static-lsbinary
Alternatively you can also in your workspace's ./vscode/settings.json you can use the following:
{
"haskell.manageHLS": "PATH",
"haskell.serverExecutablePath": "static-ls",
"haskell.serverExtraArgs": ""
}
(Note haskell.serverExecutablePath should be the path to your binary).