static-ls: See README on Github for more information

[ development, library, mit, program ] [ Propose Tags ]

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]

Flags

Manual Flags

NameDescriptionDefault
dev

Defer type errors for development

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

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]
License MIT
Author Joseph Sumabat
Maintainer josephrsumabat@gmail.com
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
Uploaded by suzzr0 at 2024-02-04T09:15:19Z
Distributions
Executables static-ls
Downloads 73 total (10 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

  1. Compile your project with ide info -fwrite-ide-info and -hiedir .hiefiles

    For 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-holes
    

    These 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:
        ghc-options:
          - -fwrite-ide-info
          - -hiedir .hiefiles
          - -fdefer-type-errors
          - -Werror=deferred-type-errors
          - -Werror=deferred-out-of-scope-variables
          - -fno-defer-typed-holes
      
      to your package.yaml. See this project's package.yaml or static-ls.cabal for examples
    • You may instead add the following to your cabal.project.local file:
      ignore-project: False
      program-options:
        ghc-options:
          -fdefer-type-errors
          -Werror=deferred-type-errors
          -Werror=deferred-out-of-scope-variables
          -fno-defer-typed-holes
      
  2. 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 hiedb where the --src-base-dir argument is not available use:

      hiedb -D .hiedb index .hiefiles
    

    entr is also recommended if you want file watching functionality:

    find -L .hiefiles | entr hiedb -D .hiedb index /_       
    
  3. Point your language client to the static-ls binary 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

Find references

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

Type on hover

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

Find definition

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

  1. Install the Haskell language extension Haskell Extension

  2. Open the extension settings Go to tsettings

  3. Scroll down until you see "Server Executable Path" and set the path to the path of your static-ls binary Set the language server executable path

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).