Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode-json-languageserver support #4164

Merged
merged 12 commits into from
Apr 30, 2022
Merged

Conversation

daliusd
Copy link
Contributor

@daliusd daliusd commented Apr 22, 2022

VSCode JSON languageserver has schema support for linting and
completions.

I have enabled snippets support (snippetSupport) even if it is not
fully supported. label that comes with completions response can be
used as well.

VSCode JSON languageserver has schema support for linting and
completions.

I have enabled snippets support (`snippetSupport`) even if it is not
fully supported. `label` that comes with completions response can be
used as well.
@daliusd
Copy link
Contributor Author

daliusd commented Apr 23, 2022

Please do not merge yet. I want to investigate some alternatives.

vscode-json-languageserver is more up-to-date (about 1 year old),
vscode-json-languageserver-bin is 4 years old.
@daliusd
Copy link
Contributor Author

daliusd commented Apr 23, 2022

Now everything is good.

@hsanson hsanson changed the title vscode-json-languageserver-bin support WIP - vscode-json-languageserver-bin support Apr 23, 2022
@daliusd
Copy link
Contributor Author

daliusd commented Apr 24, 2022

@hsanson it is not WIP anymore 😄 Unless you have some ideas what can be improved.

@daliusd daliusd changed the title WIP - vscode-json-languageserver-bin support vscode-json-languageserver support Apr 24, 2022
@daliusd
Copy link
Contributor Author

daliusd commented Apr 25, 2022

Some examples how it looks like in action:
image

image

Schema json person.json:

{
  "$id": "https://example.com/person.schema.json",
  "title": "Person",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "lastName": {
      "type": "string",
      "description": "The person's last name."
    },
    "age": {
      "description": "Age in years which must be equal to or greater than zero.",
      "type": "integer",
      "minimum": 0
    }
  }
}

Sample test file:

{
  "$schema": "./person.json",
  "firstName": "John",
  "lastName": "Doe",
  "age": 2
}

autoload/ale/completion.vim Outdated Show resolved Hide resolved
doc/ale.txt Show resolved Hide resolved
ale_linters/json/vscodejson.vim Show resolved Hide resolved
autoload/ale/completion.vim Outdated Show resolved Hide resolved
@daliusd daliusd requested a review from hsanson April 25, 2022 12:56
@@ -412,7 +412,7 @@ function! s:SendInitMessage(conn) abort
\ 'completion': {
\ 'dynamicRegistration': v:false,
\ 'completionItem': {
\ 'snippetSupport': v:false,
\ 'snippetSupport': v:true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunatelly I think this needs more evaluation. I did some tests and when this is enabled ALEImport breaks for me.
If enablinb snippetSupport is not critical for vscodejson I would recommend reverting this to get vscodejson merged and then handle adding snippetSupport on a separate issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely not critical. Let me fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsanson BTW, how ALEImport breaks for you? What filetype you were workin on? I want to reproduce the problem and see if there is a fix.

Copy link
Contributor

@hsanson hsanson Apr 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple Java HelloWorld.java managed via Gradle and using eclipselsp:

public class HelloWorld {
    public static void main(String[] argv) {
        LocalDate today = LocalDate.now();
        System.out.println("Hello gradle world at " + today);
    }
}
  1. Put the cursos in LocalDate class and invoke :ALEImport.
  2. ALE should add the import statement "import java.time.LocalDate" at the beginning of the file.
  3. With the snippetSupport enabled this does not work.

@daliusd daliusd requested a review from hsanson April 29, 2022 13:51
Copy link
Contributor

@hsanson hsanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good.

@hsanson hsanson merged commit 3489218 into dense-analysis:master Apr 30, 2022
@daliusd daliusd deleted the vscode-json branch April 30, 2022 06:30
cyyever pushed a commit to cyyever/ale that referenced this pull request Jul 11, 2022
* vscode-json-languageserver-bin support

VSCode JSON languageserver has schema support for linting and
completions.

I have enabled snippets support (`snippetSupport`) even if it is not
fully supported. `label` that comes with completions response can be
used as well.

* Test fix.

* vscode-json-languageserver instead of vscode-json-languageserver-bin

vscode-json-languageserver is more up-to-date (about 1 year old),
vscode-json-languageserver-bin is 4 years old.

* Use git root.

* Documentation update.

* Trying to sort ordering issue.

* One more attempt

* One more attempt

* Uppercase seems to win.

* Clean-up

* Clean-up 2

* Test removed.
cyyever pushed a commit to cyyever/ale that referenced this pull request Jul 11, 2022
* vscode-json-languageserver-bin support

VSCode JSON languageserver has schema support for linting and
completions.

I have enabled snippets support (`snippetSupport`) even if it is not
fully supported. `label` that comes with completions response can be
used as well.

* Test fix.

* vscode-json-languageserver instead of vscode-json-languageserver-bin

vscode-json-languageserver is more up-to-date (about 1 year old),
vscode-json-languageserver-bin is 4 years old.

* Use git root.

* Documentation update.

* Trying to sort ordering issue.

* One more attempt

* One more attempt

* Uppercase seems to win.

* Clean-up

* Clean-up 2

* Test removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants