Skip to content

Conversation

otreblan
Copy link
Contributor

This fixes neoclide/coc.nvim#911

Now man pages are correctly formatted on completionItem/resolve

Screenshot_20191210_210452

@skovhus
Copy link
Collaborator

skovhus commented Dec 11, 2019

Thanks for fixing this! Might be nice to DRY the code up a bit:

private async onCompletionResolve(
    item: LSP.CompletionItem,
  ): Promise<LSP.CompletionItem> {
    const {
      data: { name, type },
    } = item

    const getMarkdownCompletionItem = (doc: string) => ({
      ...item,
      documentation: {
        value: doc,
        kind: 'plaintext' as const
      }
    })

    try {
      if (type === 'executable') {
        const doc = await this.executables.documentation(name)
        return getMarkdownCompletionItem(doc)
      } else if (type === 'builtin') {
        const doc = await Builtins.documentation(name)
        return getMarkdownCompletionItem(doc)
      } else {
        return item
      }
    } catch (error) {
      return item
    }
  }

@skovhus skovhus self-requested a review December 11, 2019 09:41
@otreblan
Copy link
Contributor Author

Man pages syntax highlighting, also more DRY.

Screenshot_20191211_064823

Copy link
Collaborator

@skovhus skovhus left a comment

Choose a reason for hiding this comment

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

Very nice! Thanks

@skovhus skovhus merged commit 45fbd18 into bash-lsp:master Dec 11, 2019
@akurtakov
Copy link
Contributor

Man pages syntax highlighting, also more DRY.

So how is this syntax highlighting generated? I don't see anything in the commit doing so.

@otreblan
Copy link
Contributor Author

Man pages syntax highlighting, also more DRY.

So how is this syntax highlighting generated? I don't see anything in the commit doing so.

https://github.com/mads-hartmann/bash-language-server/blob/5dd9db04cae234d8f9d3d2d18153b7a1d3c16a1b/server/src/server.ts#L139

It's a markdown code block

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.

Man pages on completeopt previews are unformatted
3 participants