iamcco / diagnostic-languageserver

diagnostic language server integrate with linters
MIT License
412 stars 28 forks source link

[feature request]: `format selected range` with diagnostic-languageserver #57

Open hereGittyGitty opened 3 years ago

hereGittyGitty commented 3 years ago

Hi iamcoo,

thx a lot for 'diagnostic-languageserver'. I am trying to format visually selected python code with black or autopep8. Whenever I try to trigger the formatting with the mapping

vmap <leader>p  <Plug>(coc-format-selected)
nmap <leader>p  <Plug>(coc-format-selected)

I get the following error:

Notification error: formatSelected [ 'V' ] Error: formatRange provider not found for current buffer, your language server doesn't support it.

Formatting the whole file with the command

command! -nargs=0 Format :call CocAction('format')

works without a problem.

I did not find any related issues neither here on this site nor by using Google. Therefore I guess it must be a problem that might be only affecting me?

Here is the diagnostic-languageserver part of my coc-settings.json file that looks as unspectacular as my formatting mappings above:

{
  "languageserver": {
    "dls": {
      "command": "diagnostic-languageserver",
      "args": ["--stdio"],
      "filetypes": ["python"],
      "trace.server": "verbose",
      "initializationOptions": {
        "linters": {
          "pylint": {
            "sourceName": "pylint",
            "command": "pylint",
            "args": [
              "--output-format",
              "text",
              "--score",
              "no",
              "--msg-template",
              "'{line}:{column}:{category}:{msg} ({msg_id}:{symbol})'",
              "%file"
            ],
            "formatPattern": [
              "^(\\d+?):(\\d+?):([a-z]+?):(.*)$",
              {
                "line": 1,
                "column": 2,
                "security": 3,
                "message": 4
              }
            ],
            "rootPatterns": [".vim", ".git", "pyproject.toml", "setup.py"],
            "securities": {
              "informational": "hint",
              "refactor": "info",
              "convention": "info",
              "warning": "warning",
              "error": "error",
              "fatal": "error"
            },
            "offsetColumn": 1,
            "formatLines": 1
          }
        },
        "formatters": {
          "autopep8": {
            "command": "autopep8",
            "args": ["-"]
          },
          "black": {
            "command": "black",
            "args": ["--quiet", "-"]
          },
          "isort": {
            "command": "isort",
            "args": ["--quiet", "-"]
          }
        },
        "filetypes": {
          "python": "pylint"
        },
        "formatFiletypes": {
          "python": ["autopep8", "isort"]
        }
      }
    }
  }
}

Thank you very much for any help. If you need any more input just ask.

iamcco commented 3 years ago

It's possible but not support yet.

hereGittyGitty commented 3 years ago

Good to know so I will stop trying. Are there any plans to implement that feature in the near future? Otherwise I will look for an alternative for that exact feature in the meantime. Do you want me to create some kind of enhancement issue?

iamcco commented 3 years ago

Good to know so I will stop trying. Are there any plans to implement that feature in the near future? Otherwise I will look for an alternative for that exact feature in the meantime. Do you want me to create some kind of enhancement issue?

No plan yet, I don't have time to do that.