Code Monkey home page Code Monkey logo

elm-language-server's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elm-language-server's Issues

Get type information from line and column (LSP Hover)

We should be able to get type information given a canonical AST and a line and column number.

We can do this straightforwardly by doing the following:

  • Searching the canonical AST for typed top level function name and function arguments and giving type information
  • Searching the canonical AST for an untyped top-level function name or function arguments, then searching the module annotations to get type information

This method is limiting, as it only provides the type lookup for top level functions and arguments. The biggest limitation I can see with this is the desire to get type information of a variable declared in a let block or an anonymous function. This lead us to the following.

Alternatively, we could solve this by:

  • Searching the canonical AST for a symbol, then searching some structure by variable/type name type information

However, after digging into type constraints and the type solver, I don't see a straightforward way to get such a structure without modifying the type solver which I am reluctant to do. My concern is that this will be much easier to maintain without doing such a modification, but I also think that there is likely no way around such a thing. As a result, I will first implement the straightforward approach and move on. Then circle back to this once other basic language server features are completed.

Crashes on empy file

When creating a new elm file, the server crashes on startup. I think this has to do with the fact that the file is empty, but this is unconfirmed.

Find definition from line and column (LSP Goto Def)

We should be able to get the original place a variable was defined given a canonical AST and a line and column number.

To do this, we should be able to do the following:

  • Search the AST for the reference that the line and column is on, keeping track of all of the local variables we see
  • If the value we find is a varaible, search the local variables, top-level variables, and imports
  • If in the local module, return the location that the variable was originally defined
  • If not in the local module, find/use the variables canonical name to get to the file that we are looking for and return the location

Diagnostics from Elm Analyse (LSP Diagnostics)

This language server should be able to respond with diagnostics from elm analyse of a specific file.

For this we'd need the following:

  • Search for elm-analyse locally (in node_modules if it exists) and globally on startup
  • Run the bin on the source file when the file is changed
  • Read the response and encode in the LSP diagnostics format
  • Send encoded response

Use elm-format (LSP Formatting)

This language server should be able to format the source-code of a specific file.

For this we'd need the following:

  • Search for elm-format locally (in node_modules if it exists) and globally on startup
  • Inform the client that this language server supports formatting (if elm-format is not found, then we should not tell the client that we support formatting. See the capabilities section of the initialization spec)
  • Decode request message from client, as defined in the LSP spec
  • Using elm-format, format and save the file specified

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.