The Wayback Machine - https://web.archive.org/web/20200518011546/https://github.com/emacs-lsp/lsp-mode/issues/1340
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

Support intelephense docblock customization #1340

Open
gjm opened this issue Jan 21, 2020 · 18 comments
Open

Support intelephense docblock customization #1340

gjm opened this issue Jan 21, 2020 · 18 comments

Comments

@gjm
Copy link

@gjm gjm commented Jan 21, 2020

Intelephense's docblock generator has some nice customization settings. Would be great to expose them in lsp-mode.

See this issue for details.

@yyoncho yyoncho added the help wanted label Jan 21, 2020
@yyoncho
Copy link
Member

@yyoncho yyoncho commented Jan 21, 2020

Here it is is how to do that

'(("intelephense.trace.server" lsp-intelephense-trace-server)
if you want to provide a PR.

Also, you could set them without having a defcustom via:

(lsp-register-custom-settings
 '(("property.path" "property.value" t ))) ;; t means boolean property.
@gjm
Copy link
Author

@gjm gjm commented Jan 21, 2020

@yyoncho I'm not really fluent in elisp as to be able to provide a PR 😎

To manually set them should I do it before or after initializing lsp-mode? i.e. in :init or :config section in use-package?

@yyoncho
Copy link
Member

@yyoncho yyoncho commented Jan 21, 2020

I think that :config is the right place.

@gjm
Copy link
Author

@gjm gjm commented Jan 21, 2020

Can you please post an example of setting a json snippet? I want to set intelephense.phpdoc.functionTemplate to

{
    "summary": "$1",
    "tags": [
      "",
      "@param ${1:$SYMBOL_TYPE} $SYMBOL_NAME $2",
      "",
      "@return ${1:$SYMBOL_TYPE} $2",
      "@throws ${1:$SYMBOL_TYPE} $2"
    ]
}

Would be something like:

(lsp-register-custom-settings
 '(("intelephense.phpdoc.functionTemplate" "{....}")))

Thanks.

@yyoncho
Copy link
Member

@yyoncho yyoncho commented Jan 23, 2020

I'm not really fluent in elisp as to be able to provide a PR

It does not require elisp skills - you have several properties already defined - you just have to do the same for those who are not present.

Can you please post an example of setting a json snippet? I want to set intelephense.phpdoc.functionTemplate to

Use (list :prop1 "value-prop1" :prop2 "value-prop2") for objects and (vector "element1" "element2" ) for arrays.

@gjm
Copy link
Author

@gjm gjm commented Jan 23, 2020

To get what I described in the comment above I tried this:

(lsp-register-custom-settings
 '(("intelephense.phpdoc.functionTemplate"
    (list :summary "$1"
          :tags (vector ""
                        "@param ${1:$SYMBOL_TYPE} $SYMBOL_NAME $2"
                        ""
                        "@return ${1:$SYMBOL_TYPE} $2"
                        "@throws ${1:$SYMBOL_TYPE} $2""" "$1")))))

But this is what is sent to the server in the initialization string:

      ...
      "phpdoc": {
        "functionTemplate": [
          "list",
          "summary",
          "$1",
          "tags",
          [
            "vector",
            "",
            "@param ${1:$SYMBOL_TYPE} $SYMBOL_NAME $2",
            "",
            "@return ${1:$SYMBOL_TYPE} $2",
            "@throws ${1:$SYMBOL_TYPE} $2",
            "",
            "$1"
          ]
        ]
      }
      ...

It's all sent as arrays and not objects...

As I said earlier, I'm not skilled in elisp and I'm probably not writing it correctly. Can I get some help please?

@yyoncho
Copy link
Member

@yyoncho yyoncho commented Jan 23, 2020

Should be like that:

(lsp-register-custom-settings
 `(("intelephense.phpdoc.functionTemplate"
    ,(list :summary "$1"
          :tags (vector ""
                        "@param ${1:$SYMBOL_TYPE} $SYMBOL_NAME $2"
                        ""
                        "@return ${1:$SYMBOL_TYPE} $2"
                        "@throws ${1:$SYMBOL_TYPE} $2""" "$1")))))
@gjm
Copy link
Author

@gjm gjm commented Jan 23, 2020

As I said... I suck at elisp 😎
Thanks!

@gjm
Copy link
Author

@gjm gjm commented Jan 23, 2020

Just out of curiosity... whats the difference between ' and `?

@charles-ritchie
Copy link

@charles-ritchie charles-ritchie commented Feb 4, 2020

@gjm I am aware that inteliphense has this ability, but not how to trigger the auto completion. I imagine typing

/** 

should trigger the autocompletion, but this does not work for me.
How are you triggering the completion?

@gjm
Copy link
Author

@gjm gjm commented Feb 4, 2020

@charles-ritchie autocompletion triggers on /**C*/ where C is the cursor position. Works fine for me...

I'm assuming you know you have to buy a premium license for this to work...

@charles-ritchie
Copy link

@charles-ritchie charles-ritchie commented Feb 4, 2020

@gjm hmmm still does not work for me. I have a premium license, so must be some form of configuration issue.

@gjm
Copy link
Author

@gjm gjm commented Feb 5, 2020

@charles-ritchie are you sure your premium license is active? I had some issues with it at first. If you M-x lsp-describe-session are all of the providers enabled in the Capabilities section?

@charles-ritchie
Copy link

@charles-ritchie charles-ritchie commented Feb 10, 2020

@gjm yeah most definitely, as I am using many of the other premium features and all providers are shown as enabled for the session.

Could you possibly share your lsp-mode config?

@gjm
Copy link
Author

@gjm gjm commented Feb 10, 2020

@charles-ritchie
Copy link

@charles-ritchie charles-ritchie commented Feb 12, 2020

@gjm thanks for that. So I have quite a few extra packages for/integration with lsp-mode, so I might create a barebones emacs config and see if this helps.

@tomterl
Copy link
Contributor

@tomterl tomterl commented Feb 21, 2020

Just a hint for future searchers: You can use embedded elisp code in the templates just as in yasnippet snippets:

      (lsp-register-custom-settings
       `(("intelephense.phpdoc.functionTemplate"
          ,(list :summary "$1"
                 :tags (vector "@param ${1:$SYMBOL_TYPE} $SYMBOL_NAME $2"
                               ""
                               "@return ${1:$SYMBOL_TYPE} $2"
                               "@throws ${1:$SYMBOL_TYPE} $2"
                               "@author tregner"
                               "@since  `(tom/insert-current-date 4)`")))))

Resulting in:

    /**
     * 
     * 
     * @return int
     * @author tregner
     * @since  February 21, 2020
     */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.