Giter Club home page Giter Club logo

elm-language-server's People

Contributors

anagrius avatar andys8 avatar antew avatar bburdette avatar bengolds avatar brianhicks avatar buinauskas avatar bukkfrig avatar danielmv1 avatar dependabot[bot] avatar frawa avatar fuja0815 avatar gauteab avatar izumisy avatar jfmengels avatar jmbockhorst avatar jonmast avatar jpalardy avatar jssee avatar klassiker avatar lpil avatar lydell avatar micahhahn avatar mixmasterfresh avatar ni-ko-o-kin avatar qluxzz avatar razzeee avatar rlefevre avatar sentience avatar w0rm 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar

elm-language-server's Issues

Separate tests from normal imports/forest

At the moment features like completions etc will make it seem like they work if you import the correct things, even if that is from the testing dependencies or vice versa.

formatting is slow

There are issues with timeouts, and jankiness on formatting. But it looks like the root cause is that formatting itself is slow, and therefore execution leads to timeouts. Depending on if the plugin runs the format actions asynchronous or synchronous, the result is either no buffer update or blocking the editor for > 1s. So maybe there is something wrong, or something that can be improved. Maybe changes trigger diagnostics, and format, and format changes the text, which triggers diagnostics again? :)

Related neoclide/coc.nvim#895

documentSymbolProvider & workspaceSymbolProvider

These are basically done from my POV, but i really want feedback on the symbols we're recognizing and how we are mapping them.

This is how we map them currently.

This is a list of SymbolKind we're using:

  • File (for whole files)
  • Function (for functions)
  • Module (for a module)
  • Operator (for every operator like + or |>)
  • Enum (For custom types)
  • EnumMember (for every member of a custom type)
  • Struct (for a type alias)
  • Number (for numbers)
  • String (for strings)

These are also available in the languague server spec:

  • Namespace
  • Package (not sure these should map to imports?)
  • Class
  • Method
  • Property
  • Field (might be better for a type alias?)
  • Constructor
  • Interface
  • Variable
  • Constant
  • Boolean (should be possible have to check)
  • Array (could also be added and mapped to lists)
  • Object
  • Key
  • Null
  • Event
  • TypeParameter (not sure what this is supposed to be)

I would really like feedback here.

Working with Yarn?

Hello

I ran all the commands from the readme with yarn and I get:

rlopez ~/R/p/elm-language-server *master λ y link
yarn link v1.16.0
success Registered "@elm-tooling/elm-language-server".
info You can now run `yarn link "@elm-tooling/elm-language-server"` in the projects where you want to use this package and it will be used instead.
Done in 0.07s.

And using: elm-language-server --stdio gives:

fish: Unknown command elm-language-server

Rename not working for arguments

add: Int -> Int -> Int
add a b =
    a + b

rename a to x -> no changes


[Trace - 3:38:42 PM] Sending request 'textDocument/rename - (31)'.
Params: {
    "textDocument": {
        "uri": "file:///home/as/Dev/repository/vim-emulation/src/Main.elm"
    },
    "position": {
        "line": 689,
        "character": 4
    },
    "newName": "x"
}


[Trace - 3:38:42 PM] Received response 'textDocument/rename - (31)' in 2ms.
Result: {
    "changes": {}
}

Coc / Vim

`elm-analyse.json` is getting ignored

I haven't been able to fully track down why, but settings in elm-analyse.json are getting ignored. As an example, if you have:

{
    "checks": {
        "ImportAll": false
    },
}

elm-ls still reports ImportAll warnings.

From my digging, it looks like the port that loads elm-analyse.json is getting initialized correctly:
From file-loading-ports to context.

I haven't poked the internals of elm-analyse to understand why it's ignoring them.

Repetetive types

There's quite a lot of repetitive types that are inlined within generic types, such as arrays.

For instance:

private findElmFilesInFolders(
  elmFolders: Array<{ path: string; writable: boolean }>,
): Array<{ path: string; writable: boolean }> {
  let elmFilePaths: Array<{ path: string; writable: boolean }> = [];
  for (const element of elmFolders) {
    elmFilePaths = elmFilePaths.concat(this.findElmFilesInFolder(element));
  }
  return elmFilePaths;
}

private findElmFilesInFolder(element: {
  path: string;
  writable: boolean;
}): Array<{ path: string; writable: boolean }> {
  return glob
    .sync(`${element.path}/**/*.elm`)
    .map(a => ({ path: a, writable: element.writable }));
}

The following type appears 4 times in snippet above.

{ path: string; writable: boolean }

This could be extracted into a separate interface. This will improve readability and reduce code duplication.

formatProvider

The format provider uses elm-format and should be done.

  • Testing
  • Bugfixes
  • Possibility to give the path to your elm-format if it's not installed global

It works fine for me on windows, but linux says it doesn't find a global installation, I do have one. So it might be my linux or a problem in general.
No idea about macOS

Test dependencies are ignored / not implemented

Issue

UNKNOWN IMPORT - The MainTest module has a bad import: import Test I cannot find that module! Is there a typo in the module name? The "source-directories" field of your elm.json tells me to only look in the src directory, but it is not there. Maybe it is in a package that is not installed yet?

Cause

Currently direct dependencies are read, but test-dependencies are not. This will lead to

const dependencies: { [index: string]: string } =
type === "application"
? elmJson.dependencies.direct
: elmJson.dependencies;

elm.json Structure

    "dependencies": {
        "direct": {
        },
        "indirect": {
        }
    },
    "test-dependencies": {
        "direct": {
        },
        "indirect": {
        }
    }

Solution

For now it's probably an improvement to add test-dependencies. In the long term there needs to be some distinction between dependency types, to disallow importing test dependencies in source files.

codeLens provider

Shows if a function or type is exposed or not. Doesn't offer anything more right now.

Other things we could do:

  • Add command to expose/unexpose
  • Add useage counter and command to show all useages

Add install instructions to README.md

There is no mention of installing the elm-language-server executable in the readme, there's no releases available either. The closest thing there to install instructions is the editor support section, but without the executable available those wont work (I've tried).

Installation instructions seem like a pretty standard thing to include in a readme, some might say its the most important thing. If there's a reason they are not present, than this readme should at least include a note addressing the exclusion of them.

diagnosticProviders

We currently have two ways diagnostics are generated, there might be more in the future:

  • elm make

  • elm analyse

  • Testing

  • Bugfixes

  • Possibility to give the path to both if they're not installed global

Elm analyse works fine on windows for me.
Elm make tries to open the generated elm.js every time it runs. Pretty weird, hopefully just something that happens when you run the dev version.

Linux says it doesn't global installations, I do have them. So it might be my linux or a problem in general.
No idea about macOS.

completionProvider

We want to autocomplete on everything that is imported like:

  • Local Functions or functions from imported files
    • Local available functions due to let
  • local Types or from imported files
    • type constructors
  • local Type alias or from imported files
  • Modules as imported (and as they export)
    These should also all get documentation added similar to the ones used for hover.

Keep in mind most can be prefixed/aliased

Stuff we need utils and core extension for:

  • ask the client where the elm exec is, to be able to find package files
  • Add imports that are imported by default via the compiler

Later:
We might also want a list of other available functions, types that are not imported yet.

Basic set of language server features

We basically want all that applies from here https://code.visualstudio.com/api/language-extensions/programmatic-language-features

I crossed out the ones I think don't make sense, please comment if you disagree. We can still decide in each issue if any of these don't work for elm

referencesProvider

Find the all references for:

  • Functions
  • Types
  • Type alias
  • Modules

Even from other files or when they're prefixed/aliased

commandProvider

Commands supplied by the old vscode implementation

name Description Keyboard
elm.replStart Elm: REPL - Start  
elm.replSendLine Elm: REPL - Send Line Alt+/
elm.replSendSelection Elm: REPL - Send Selection Alt+Enter  
elm.replSendFile Elm: REPL - Send File  
elm.reactorStart Elm: Reactor - Start  
elm.reactorStop Elm: Reactor - Stop    
elm.make Elm: Make Ctrl+F5
elm.makeWarn Elm: Make --warn  
elm.install Elm: Install packages/dependencies    
elm.browsePackage Elm: Browse packages/dependencies documentation    
elm.clean Elm: Clean build artifact  
elm.analyseStart Elm: Start elm-analyse  
elm.analyseStop Elm: Stop elm-analyse

We need to figure out which ones we want to have. The elm analyse ones could be ignored for now.

@elm-tooling/elm-language-server is not working

Hi.
I tried to use @elm-tooling/elm-language-server - npm with coc.nvim.

$ npm i -g @elm-tooling/elm-language-server
    "elmLS": {
      "command": "elm-language-server",
      "args": [
        "--stdio"
      ],
      "filetypes": [
        "elm"
      ],
      "rootPatterns": [
        "elm.json"
      ],
      "initializationOptions": {
        "runtime": "node",
        "elmPath": "elm",
        "elmFormatPath": "elm-format",
        "elmTestPath": "elm-test"
      }
    },

I opened elm file, err occurred.

[coc.nvim] Server elmLS failed to start: Request initialize failed unexpectedly without providing any details.

This language server has outputted this message(:CocCommand workspace.showOutput).

[Trace - 5:27:44 PM] Sending request 'shutdown - (1)'.
[Trace - 5:27:44 PM] Received response 'shutdown - (1)' in 2ms.
No result returned.


[Trace - 5:27:44 PM] Sending notification 'exit'.
No parameters provided.

My env is as follows.

$ node -v
v11.12.0
$ npm --version
6.7.0
$ elm --version
0.19.0
$ elm-format --help
elm-format 0.8.1
$ elm-test --version
0.19.0-rev6
$ vim -v
NVIM v0.4.0-dev

additional info

This language server works correctly if I create binary as described in README.

$ npm install
$ npm run compile
$ npm link

Vim and Coc install instructions not working

Hi! I'm trying to use it with NeoVim and Coc, but it doesn't work.
Here is the error that pops up whenever I open an Elm file:

[coc.nvim] Server elm failed to start: Command "elm-ls" of languageserver.elm is not executable: Error: not found: elm-ls

And here is the Coc configuration file:

{
  "suggest.minTriggerInputLength": 1,
  "languageserver": {
    "elm": {
      "command": "elm-ls",
      "args": ["--stdio"],
      "filetypes": ["elm"],
      "rootPatterns": ["elm.json"],
      "initializationOptions": {
        "runtime": "node",
      }
    }
  }
}

It doesn't find the elm-ls executable, but there are no standalone install instructions. What am I missing?
Thanks in advance :)

Improve snippet descriptions

With the new way we're doing snippets, we can use markdown for the descriptions now.

  • Use markdown to make descriptions nice
  • Remove too simple snippets
  • Change labels, where they could be improved recordtype should become typeAlias etc

renameProvider

Find all renames for:

  • Functions
  • Types
  • Type alias
  • Modules

Even from other files or when they're prefixed/aliased.

This is pretty similiar to the hoverProvider & definitionProvider, so they could likely share big parts of their code.

But be aware, there are even places that probably don't show up in our definition (or references) provider, that we want to rename. Like a functions type definition.

Make sure we don't edit files outside of our scope, that are in our package cache or similar.

Downloading treesitter on every editor start

It looks like it is downloading treesitter on start. Is it cached? Can we move this to the npm install step? (coc/vim)

[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Rebuilding tree-sitter for local Electron version"
}


[Info  - 10:45:18 PM] Rebuilding tree-sitter for local Electron version
[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Fetching tree-sitter"
}


[Info  - 10:45:18 PM] Fetching tree-sitter
[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Downloading from https://github.com/tree-sitter/node-tree-sitter/releases/download/v0.14.0/tree-sitter-v0.14.0-node-v67-linux-x64.tar.gz"
}


[Info  - 10:45:18 PM] Downloading from https://github.com/tree-sitter/node-tree-sitter/releases/download/v0.14.0/tree-sitter-v0.14.0-node-v67-linux-x64.tar.gz
[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Fetching tree-sitter-elm"
}


[Info  - 10:45:18 PM] Fetching tree-sitter-elm
[Trace - 10:45:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Downloading from https://github.com/razzeee/tree-sitter-elm/releases/download/v2.2.4/tree-sitter-elm-v2.2.4-node-v67-linux-x64.tar.gz"
}


[Info  - 10:45:18 PM] Downloading from https://github.com/razzeee/tree-sitter-elm/releases/download/v2.2.4/tree-sitter-elm-v2.2.4-node-v67-linux-x64.tar.gz
[Trace - 10:45:19 PM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Rebuild succeeded!"
}


[Info  - 10:45:19 PM] Rebuild succeeded!
[Trace - 10:45:19 PM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "initializing - folder: \"file:///home/as/Dev/repository/vim-emulation/\""
}

completionProvider v2

  • Local available functions due to let
  • Local available parameters from functions wrapping
  • Complete on type alias access
  • Complete parameters from switch

Context sensitive completions:

  • Complete imports
    • Exposing list
    • Import name
  • Complete modules
    • Exposing list
    • Disable completions for module name

Completion useage

At the moment we add completions for sub types/functions to a list, e.g. Html.div
But that doesn't really play nice with the spec, as you might end up typing Html. then auto complete. Under certain prerequisites this leads to Html.Html.div which is not what we want.

Typescript or C# would first let you choose Html then would detect that the completion your expanding on is in the Html package and only send the correct functions.

Problem with tree-sitter

Hi, I'm really excited about this thing because I love Elm, and I'd like to use it in my preferred environment, which is actually emacs.

This may just be me being dumb, but I keep getting:

[Trace - 06:25:31 PM]
Received notification 'window/logMessage'.

Params:
{
"message": "Rebuilding tree-sitter for local Electron version",
"type": 3
}

and then nothing after that. I've run npm install in the root directory, and in the client directory and server directory. Is there anything else that I need to do to get tree-sitter/the server to work?

Thanks for this project, and thanks in advance for any help you can give me!

Errors don't disappear when last error is from elm-make

Repro steps:

  1. Get a file to have only one elm-make error and no elm-analyse warning.
  2. Fix the elm-make error.

Expected:
No errors reported.

Observed:
Last elm-make error still appears in diagnostics.

This doesn't happen if the last error is an elm-analyse warning.

(Note: observed in both VSCode and vim)

codeActions provider

This is a quite open-ended provider that would be the main place for us to integrate refactoring capabilities.

The codeAction spec has some pre-defined Code Action namespaces. I think some editors may display the code actions to the user differently based on the namespace of each action. Some features to support (and their corresponding namespaces) would be:

Base kind for quickfix actions: 'quickfix'

  • Add type annotation
  • Automatically add import (if a user uses a value from a package they haven't imported yet, add an import line)
  • Replace with... (suggestion for types from elm-make)
  • Add missing case patterns
  • Install package

Base kind for refactoring extraction actions: 'refactor.extract'

  • Extract to let statement
  • Extract to new function
  • Extract to type alias

Base kind for refactoring inline actions: 'refactor.inline'

  • Inline let statement
  • Inline function
  • Inline type alias

Base kind for refactoring rewrite actions: 'refactor.rewrite'

  • Qualify/unqualify imported value
  • Reorder parameters

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.