Lsp-mode: Support intelephense docblock customization

Created on 21 Jan 2020  路  18Comments  路  Source: emacs-lsp/lsp-mode

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

See this issue for details.

good-first-issue help wanted

All 18 comments

Here it is is how to do that
https://github.com/emacs-lsp/lsp-mode/blob/843000b373b2ab50a2c14742acffacaee2be6edc/lsp-intelephense.el#L153 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.

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

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

I think that :config is the right place.

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.

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.

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?

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")))))

As I said... I suck at elisp :sunglasses:
Thanks!

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

@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?

@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...

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

@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?

@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?

@charles-ritchie sure... It's quite simpe..

https://gist.github.com/gjm/e4e7ec1c345c24b964eb62edcd88d58a

@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.

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
     */
Was this page helpful?
0 / 5 - 0 ratings