Coder Social home page Coder Social logo

fwcd / curry-language-server Goto Github PK

View Code? Open in Web Editor NEW
23.0 7.0 3.0 649 KB

IDE support for the functional logic language Curry

License: BSD 3-Clause "New" or "Revised" License

Haskell 99.27% Curry 0.06% Python 0.67%
curry functional-programming logic-programming language-server-protocol haskell

curry-language-server's Introduction

Curry Language Server

Build Haskell BSD3 License

An experimental language server providing IDE support for the functional logic programming language Curry.

Screenshot

Building

To build the language server, you will need the build tool Haskell Stack. Once installed, you can run stack build to build the language server.

The final executable will be located in $(stack path --dist-dir)/build/curry-language-server.

If you wish to use the language server in an editor, you can also use stack install to install the binary into ~/.local/bin. By adding this directory to your PATH, invoking curry-language-server will work from any directory.

Editor Integration

To use the language server, you will need an editor that supports LSP. This usually involves pointing the LSP client towards the built executable and setting the transport method to stdio.

For Visual Studio Code, this extension can be used.

Known Issues

If the language server has trouble locating an interface for the Prelude, you may need to add your Curry compiler's lib directory to your import paths, e.g. in your config under curry.languageServer.importPaths or in <your project path>/.curry/language-server/paths.json (which is a string array of import paths). Alternatively, you may also place a compiled version (Prelude.icurry) in the folder <your workspace path>/.curry/language-server.

curry-language-server's People

Contributors

fwcd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

curry-language-server's Issues

Version the `.curry/language-server` folder

We'd want to make sure that different versions of the language server can coexist, even if we make breaking changes to the ICurry format (e.g. as proposed in #26 (comment)).

Therefore we should include the language server version in the output directory path (e.g. .curry/language-server-x.y.z) and make sure this version number is bumped (at least) every time there is a breaking change in one of the serialized formats.

Investigate vendoring libs and cpm

Similar to the existing Curry compilers (PAKCS and KiCS2) we could vendor our own versions of the libraries and the CPM as Git submodules to remove the runtime dependency on an existing Curry compiler (which is currently configured to use pakcs by default and configurable as curry.languageServer.curryPath).

Add suggestion quick fixes

E.g.

  • Pointfree conversions
    • Eta-reductions (\x -> f x to f)
    • Const (\_ -> x to const x)
    • Void (x >> return () to void x)
    • ...
  • Common library functions (maybe x id m to fromMaybe x m, fst . runState to evalState, snd . runState to execState, ...)
  • Redundant dos (do { x } to x)
  • Merging adjacent lets
  • Warn (or at least 'info') about Debug.Trace imports
  • ...

These suggestions could be similar to what hlint suggests.

Implement Quick Fixes

The language server protocol provides a way for "quick fixes"/refactorings to be displayed in the editor:

Screenshot

Ideally, we could implement this for Curry to provide fixes for errors (ideally from the frontend) and suggestions (see #34).

Implement signature help

The language server protocol provides a way to dynamically display the currently edited parameter of a function:

image

Implementing this for Curry would involve figuring out which argument the user currently edits and determine when to "close" the window (e.g. since Curry support partial application/currying, the user does not have to specify all arguments).

Add arm64 macOS build

Now that GitHub has free M1 runners for open-source, we should investigate providing arm64 macOS binaries in our releases.

Support definition lookup on module identifiers

Currently, we only support it on qualified identifiers. We could extend this by

  • ...adding a HasModuleIdentifiers class to Curry.LanguageServer.Utils.Syntax
  • ...generalizing resolveQualIdentAtPos to resolve module identifiers too
    • We'd probably also want to rename the function then

Tag unused warnings

Add the unused tag to the corresponding diagnostics (e.g. so that an LSP client can render them in a special way).

Implement Find References

Implement the LSP feature for finding references to a symbol, e.g. looking up all occurrences of a variable.

Detect data import wildcards (X (..)) as imported

Consider the following Curry modules:

-- A.curry
module A where

data X = X { unX :: Int }
-- B.curry
module B where

import A (X (..))

test :: Int
test = _

Entering unX at _ currently suggests an auto-import, even though it is not required.

Add an evaluation code lens

Similar to the Haskell language server, add an evaluation code lens. This could use the configured Curry executable (curry.languageServer.curryPath, which is pakcs by default) and then invoke it e.g. like this:

pakcs :load [current module] :eval [expression] :quit

Caching

Store compiled ASTs in memory and only recompile on changes.

Add code completions for `OPTIONS_FRONTEND` flags

It would be cool if the language server could provide code completions for the frontend's flags, e.g. -Wno-missing-signatures in OPTIONS_FRONTEND pragmas. Ideally, the language server would query the available flags directly from the frontend.

Use a virtualized file system

Currently, linting and updates to the symbol database are first performed once a user saves the file. Using a virtual file system we could provide linting in real-time as the user types.

This would involve figuring out how to compile in-memory files using the Curry frontend or, alternatively, regularly saving the text buffer to a temporary file.

Respect `OPTIONS_FRONTEND` settings

For example, setting {-# OPTIONS_FRONTEND -Wno-missing-signatures #-} should cause warnings about missing top-level signatures to disappear.

Hoogle-like API search

Integrate Hoogle-like API search, in a similar fashion as Currygle.

Implementation notes:

  • This could e.g. be implemented as part of a WorkspaceSymbols query

Context-aware code completions

Provide context-aware code completions based on whether the user is currently in a type, value or qualifier context (imports/qualified identifiers).

Interface for module Prelude not found

Screenshot 2023-12-05 at 5 02 23 am

It also says this

Screenshot 2023-12-05 at 5 04 20 am

Im getting this error on a fresh cypm new template. Not entirely sure what the problem is, any ideas?

Extra details:
M1 MacOS 14.1.2
Using PAKCS 3.6.1-b1 of 2023-11-16 (swi 9.0)

Cannot find infix operators

In source code like [1,2] ++ [3,4], hovering ++ shows the type, but when trying to go the definition, it shows No definition found. However, in code like (++) [1,2] [3,4], it works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.