{"id":13709368,"url":"https://github.com/nwolverson/purescript-language-server","last_synced_at":"2025-06-11T14:37:22.433Z","repository":{"id":38552452,"uuid":"104399882","full_name":"nwolverson/purescript-language-server","owner":"nwolverson","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-02T10:03:42.000Z","size":1537,"stargazers_count":194,"open_issues_count":34,"forks_count":43,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-13T09:08:02.511Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PureScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nwolverson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-21T21:17:07.000Z","updated_at":"2025-02-21T18:01:10.000Z","dependencies_parsed_at":"2024-06-19T10:00:14.638Z","dependency_job_id":"2b8cb2dc-d00e-4fea-9477-89bf44628fc3","html_url":"https://github.com/nwolverson/purescript-language-server","commit_stats":{"total_commits":380,"total_committers":26,"mean_commits":"14.615384615384615","dds":"0.22894736842105268","last_synced_commit":"babd5f734d3a9cb1432f1f5e881d19d27b4a1cbf"},"previous_names":[],"tags_count":66,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwolverson%2Fpurescript-language-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwolverson%2Fpurescript-language-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwolverson%2Fpurescript-language-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwolverson%2Fpurescript-language-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nwolverson","download_url":"https://codeload.github.com/nwolverson/purescript-language-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwolverson%2Fpurescript-language-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259280753,"owners_count":22833438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:00:38.503Z","updated_at":"2025-06-11T14:37:22.384Z","avatar_url":"https://github.com/nwolverson.png","language":"PureScript","funding_links":[],"categories":["Languages","Essential tools"],"sub_categories":[],"readme":"# PureScript language server\n\nNode-based Language Server Protocol server for PureScript based on the PureScript IDE server\n(aka psc-ide / `purs ide server`). Used as the [vscode plugin](https://github.com/nwolverson/vscode-ide-purescript)\nbackend but should be compatible with other Language Server Client implementations.\n\nThe language server is a wrapper around the IDE server included as part of the compiler distribution,\nproviding editing assistance and build features according to support available. This means that\nthe server will start its own `purs ide server` instance to talk to for the project directory it is started\nin.\n\n## Features\n\n- Completion provider\n- Definition provider\n- Formatting provider\n- Document \u0026 workspace symbol providers\n- Hover provider\n- Code action provider\n  - Compiler fix suggestions for imports/missing types\n- Build on save (via IDE server \"fast rebuild\" facility, certain limitations apply)\n  - Provides diagnostics\n- Commands\n  - Build (full build via `purs compile` / configured build command) - provides diagnostics\n  - Case split\n  - Add clause\n  - Replace suggestion\n  - Add completion import\n  - Start IDE server\n  - Stop IDE server\n  - Restart IDE server\n- Config\n  - `purescript.*`\n\n## Usage\n\nThis LSP implmementation is consumed by vscode and Atom plugins as a node module, and bundled along with those plugins.\n\nTo use with another LSP client, you will want to install this either globally or locally for `npm`, e.g.\n\n```\nnpm i -g purescript-language-server\n```\nAnd then use the resulting executable, e.g. `purescript-language-server --stdio`.\n\nThis language server is based on vscode-languageserver-node which means it should support `--stdio`, `--socket=[number]`, `--node-ipc` or `--pipe` methods of communication, see [vscode-languageserver-node](https://github.com/Microsoft/vscode-languageserver-node) for details.\n\n#### Version support policy\n\nPureScript compiler version support is as follows:\n\n* The current minor version of the compiler is supported at all patch versions (e.g. 0.14.xx)\n* The previous minor version of the compiler is supported at the latest patch version (e.g. 0.13.8) for new functionality, and where possible all patch versions for existing functionality\n* Any older compiler versions are not officially supported - they may continue to work and will not be intentionally broken, but no particular effort will be made for continued support in the face of API changes\n\n### Formatting provider\n\nThe `purescript-language-server` comes with support for formatting PureScript code via several external tools, exposed as a standard LSP formatting provider. When a formatting operation is requested, `purescript-language-server` will attempt to find the configured tool via its standard name in your `$PATH` (or the local `npm` install path if `purescript.addNpmPath` is set).\n\nThe formatting tool is selected via `purescript.formatter`, with the following options\n\n  * No formatter - simply leave the setting unset or empty (default)\n  * [`purs-tidy`](https://github.com/natefaubion/purescript-tidy) (or simply `tidy`). If you do not have any existing preferences this would be the suggested pick.\n  * [`pose`](https://github.com/rowtype-yoga/pose)\n  * [`purty`](https://gitlab.com/joneshf/purty) \n\n### VSCode \n\nUse [vscode-ide-purescript](https://github.com/nwolverson/vscode-ide-purescript).\n\n### Atom\n\nUse [atom-ide-purescript](https://github.com/nwolverson/atom-ide-purescript).\n\n## Neovim’s built-in language server + nvim-lspconfig\n\nAs of `0.5.0`, Neovim has a built-in [language server client](https://neovim.io/doc/user/lsp.html). A popular plugin to help with configuring this server is [`nvim-lspconfig`](https://github.com/neovim/nvim-lspconfig/blob/master/README.md). This plugin includes `purescriptls` which will automatically find and root the language server as well as connect PSCIDE, etc. (for more info, read the [config](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#purescriptls)). To use, add this to your `init.lua` or inside a `EOF \u003c\u003c lua … EOF` block in your `init.vim`.\n\n```lua\nnvim_lsp.purescriptls.setup {\n  \" Your personal on_attach function referenced before to include\n  \" keymaps \u0026 other ls options\n  on_attach = on_attach,\n  settings = {\n    purescript = {\n      addSpagoSources = true -- e.g. any purescript language-server config here\n    }\n  },\n  flags = {\n    debounce_text_changes = 150,\n  }\n}\n```\n\n### NeoVim plugin that adds more commands, designed to supplement built-in language server\n\nUse [nvimmer-ps](https://github.com/srghma/nvimmer-ps).\n\n\n### Vim/LSP\n\nAuto configuration with [vim-lsp-settings](https://github.com/mattn/vim-lsp-settings)\n\n### Vim/CoC\n\nConfiguration with [coc.nvim](https://github.com/neoclide/coc.nvim/wiki/Language-servers#purescript)\n\nRun `:CocConfig` and add `\"purescript\"` in the `\"languageserver\"` section as follows:\n\n```jsonc\n  \"languageserver\": {\n    \"purescript\": {\n      \"command\": \"purescript-language-server\",\n      \"args\": [\"--stdio\"],\n      \"filetypes\": [\"purescript\"],\n      \"trace.server\": \"off\",\n      \"rootPatterns\": [\"bower.json\", \"psc-package.json\", \"spago.dhall\"],\n      \"settings\": {\n        \"purescript\": {\n          \"addSpagoSources\": true,\n          \"addNpmPath\": true, // Set to true if using a local purty install for formatting\n          \"formatter\": \"purs-tidy\"\n          // etc\n        }\n      }\n    }\n  }\n```\n\nCoC can be configured to format your code using the `purescript-language-server`'s formatting provider, which is backed by `purty`. If you don't have CoC-based code formatting setup in CoC already, you can add a command or key mapping like this:\n\n```vim\ncommand! -nargs=0  Format      :call CocAction('format')\nnmap               \u003cleader\u003ef   :Format\u003ccr\u003e\n```\n\nIf you want the formatter to run on save, run `:CocConfig` and add `\"purescript\"` to the `\"coc.preferences.formatOnSaveFiletypes\"`:\n\n```jsonc\n  \"coc.preferences.formatOnSaveFiletypes\": [\n    // ...other languages\n    \"purescript\"\n  ]\n\n```\n\nYou can also organize PureScript imports in Vim with a command and/or key mapping like this:\n\n```vim\ncommand! -nargs=0  OrganizeImports :call CocAction('runCommand', 'editor.action.organizeImport')\nnmap               \u003cleader\u003eo       :OrganizeImports\u003ccr\u003e\n```\n\n### Vim/LanguageClient_neovim\n\nUse [vimmer-ps](https://github.com/sriharshachilakapati/vimmer-ps).\n\n\n### Other clients\n\nConfig may be supplied via client-push on startup (`workspace.didChangeConfiguration`), server-request (`workspace.configuration`), or at last resort by JSON object on the command line with `--config` option.\n\n## Config\nSee [config defined in vscode plugin](https://github.com/nwolverson/vscode-ide-purescript/blob/master/package.json).\n\n### Usage with alternate backends\n\nWhen using the language server together with alternate backends, the only requirement is to stop `purs ide server` from attempting to generate JS when rebuilding, this is done via the config\n\n```json\n\"purescript.codegenTargets\": [ \"corefn\" ]\n```\n\n(and you should make sure the build command is in accordance with that, if used, eg specify `backend` in `spago` config).\n\n## Commands\n\nVarious commands are provided. Some are triggered via completion etc, some must be called explicitly from a LSP client.\n\n### `purescript.build`\n\nNo arguments. Provides diagnostics.\n\n### `purescript.startPscIde`\n\nNo arguments. Start IDE server according to configuration.\n\n### `purescript.stopPscIde`\n\nNo arguments. Stop running IDE server.\n\n### `purescript.restartPscIde`\n\nNo arguments. Stop any running IDE server then start a new one according to configuration.\n\n### `purescript.addCompletionImport`\n\nArguments: identifier, module, document URI.\n\n### `purescript.addModuleImport`\n\nArguments: module, qualifier, document URI.\n\n### `purescript.getAvailableModules`\n\nNo arguments. Get list of available modules.\n\n### `purescript.replaceSuggestion`\n\nArguments: document URI, replacement, replacement range.\n\n### `purescript.search`\n\nFlex search for identifier.\n\nArguments: search text.\n\n### `purescript.fixTypo`\n\nArguments: document URI, line, character.\n\n### `purescript.caseSplit-explicit`\n\n(Used to back the case split command in VS Code UI).\n\nArguments: document URI, line, character, type.\n\n### `purescript.addClause-explicit`\n\n(Used to back the add clause command in VS Code UI).\n\nArguments: document URI, line, character.\n\n### `purescript.typedHole-explicit`\n\n(Used to back the `purescript.typedHole` code action triggered in the VS Code UI)\n\nArguments: hole name, document URI, hole range, `PscIde.Command.TypeInfo` of chosen replacement option\n\n\n## Development\n\nTo develop (rather than use) this language server\n\n1. Clone this repo and `npm install`\n2. Make changes and `npm run build`\n3. Ensure the built module is picked up by your editor\n\nFor 3, if the editor integrates using the node module rather than standalone binary, I suggest using `npm link` - this will work for atom and vscode at least.\n\nFor atom, clone `atom-ide-purescript` and:\n\n1. In `purescript-language-server` run `npm link`, in `atom-ide-purescript` run `npm link purescript-language-server`\n2. In `atom-ide-purescript` run `apm link` to pick up local changes\n3. In `atom-ide-purescript`, run `npm run bundle` to build the plugin itself\n4. Reload any atom window to pick up changes\n\nFor vscode, clone `vscode-ide-purescript` and:\n\n1. Run `npm install`\n1. In `purescript-language-server` run `npm link`, in `vscode-ide-purescript` run `npm link purescript-language-server`\n1. Open `vscode-ide-purescript` in vscode (`code .`) and hit F5 to \"launch extension\"\n1. Use the newly launched Extension Development Host to test language server changes\n\nSee [vscode plugin](https://github.com/nwolverson/vscode-ide-purescript) repo, [atom plugin](https://github.com/nwolverson/atom-ide-purescript). Common code via\n[purescript-ide-purescript-core](https://github.com/nwolverson/purescript-ide-purescript-core).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwolverson%2Fpurescript-language-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnwolverson%2Fpurescript-language-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwolverson%2Fpurescript-language-server/lists"}