How to use the vscode-languageserver-protocol.MarkupContent.is function in vscode-languageserver-protocol

To help you get started, we’ve selected a few vscode-languageserver-protocol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neoclide / coc.nvim / src / handler / index.ts View on Github external
}
            lines.push(...content.trim().split('\n'))
            docs.push({ filetype: item.language, content: item.value })
          }
        }
      } else if (typeof contents == 'string') {
        lines.push(...contents.split('\n'))
        docs.push({ content: contents, filetype: 'markdown' })
      } else if (MarkedString.is(contents)) { // tslint:disable-line
        let content = contents.value.trim()
        if (target == 'preview') {
          content = '``` ' + contents.language + '\n' + content + '\n```'
        }
        lines.push(...content.split('\n'))
        docs.push({ filetype: contents.language, content: contents.value })
      } else if (MarkupContent.is(contents)) {
        lines.push(...contents.value.split('\n'))
        docs.push({ filetype: contents.kind == 'markdown' ? 'markdown' : 'txt', content: contents.value })
      }
      i++
    }
    if (target == 'echo') {
      const msg = lines.join('\n').trim()
      if (msg.length) {
        await this.nvim.call('coc#util#echo_hover', msg)
      }
    } else if (target == 'float') {
      diagnosticManager.hideFloat()
      await this.hoverFactory.create(docs)
    } else {
      this.documentLines = lines
      let arr = await this.nvim.call('getcurpos') as number[]
github neoclide / coc.nvim / src / handler / index.ts View on Github external
}
            lines.push(...content.trim().split('\n'))
            docs.push({ filetype: item.language, content: item.value })
          }
        }
      } else if (typeof contents == 'string') {
        lines.push(...contents.split('\n'))
        docs.push({ content: contents, filetype: 'markdown' })
      } else if (MarkedString.is(contents)) { // tslint:disable-line
        let content = contents.value.trim()
        if (target == 'preview') {
          content = '``` ' + contents.language + '\n' + content + '\n```'
        }
        lines.push(...content.split('\n'))
        docs.push({ filetype: contents.language, content: contents.value })
      } else if (MarkupContent.is(contents)) {
        lines.push(...contents.value.split('\n'))
        docs.push({ filetype: contents.kind == 'markdown' ? 'markdown' : 'txt', content: contents.value })
      }
      i++
    }
    if (target == 'echo') {
      await this.nvim.call('coc#util#echo_hover', lines.join('\n').trim())
    } else if (target == 'float') {
      diagnosticManager.hideFloat()
      await this.hoverFactory.create(docs)
    } else {
      this.documentLines = lines
      await this.nvim.command(`pedit coc://document`)
    }
  }
github neoclide / coc.nvim / src / handler / index.ts View on Github external
if (paramDoc) {
          let content = typeof paramDoc === 'string' ? paramDoc : paramDoc.value
          if (content.trim().length) {
            p.push({
              content,
              filetype: MarkupContent.is(c.documentation) ? 'markdown' : 'txt'
            })
          }
        }
        if (idx == 0 && c.documentation) {
          let { documentation } = c
          let content = typeof documentation === 'string' ? documentation : documentation.value
          if (content.trim().length) {
            p.push({
              content,
              filetype: MarkupContent.is(c.documentation) ? 'markdown' : 'txt'
            })
          }
        }
        return p
      }, [])
      let offset = 0
github neoclide / coc.nvim / src / handler / index.ts View on Github external
if (paramDoc) {
          let content = typeof paramDoc === 'string' ? paramDoc : paramDoc.value
          if (content.trim().length) {
            p.push({
              content,
              filetype: MarkupContent.is(c.documentation) ? 'markdown' : 'txt'
            })
          }
        }
        if (idx == 0 && c.documentation) {
          let { documentation } = c
          let content = typeof documentation === 'string' ? documentation : documentation.value
          if (content.trim().length) {
            p.push({
              content,
              filetype: MarkupContent.is(c.documentation) ? 'markdown' : 'txt'
            })
          }
        }
        return p
      }, [])
      await this.signatureFactory.create(docs, true)
github neoclide / coc.nvim / src / handler / index.ts View on Github external
}
        }
        if (activeIndexes == null) {
          activeIndexes = [nameIndex + 1, nameIndex + 1]
        }
        p.push({
          content: c.label,
          filetype: document.filetype,
          active: activeIndexes
        })
        if (paramDoc) {
          let content = typeof paramDoc === 'string' ? paramDoc : paramDoc.value
          if (content.trim().length) {
            p.push({
              content,
              filetype: MarkupContent.is(c.documentation) ? 'markdown' : 'txt'
            })
          }
        }
        if (idx == 0 && c.documentation) {
          let { documentation } = c
          let content = typeof documentation === 'string' ? documentation : documentation.value
          if (content.trim().length) {
            p.push({
              content,
              filetype: MarkupContent.is(c.documentation) ? 'markdown' : 'txt'
            })
          }
        }
        return p
      }, [])
      let offset = 0
github neoclide / coc.nvim / src / handler / index.ts View on Github external
} else {
              activeIndexes = active.label
            }
          }
        }
        p.push({
          content: c.label,
          filetype: document.filetype,
          active: activeIndexes
        })
        if (paramDoc) {
          let content = typeof paramDoc === 'string' ? paramDoc : paramDoc.value
          if (content.trim().length) {
            p.push({
              content,
              filetype: MarkupContent.is(c.documentation) ? 'markdown' : 'txt'
            })
          }
        }
        if (idx == 0 && c.documentation) {
          let { documentation } = c
          let content = typeof documentation === 'string' ? documentation : documentation.value
          if (content.trim().length) {
            p.push({
              content,
              filetype: MarkupContent.is(c.documentation) ? 'markdown' : 'txt'
            })
          }
        }
        return p
      }, [])
      await this.signatureFactory.create(docs, true)
github wylieconlon / lsp-editor-adapter / src / codemirror-adapter.ts View on Github external
end = {
        line: response.range.end.line,
        ch: response.range.end.character,
      } as CodeMirror.Position;

      this.hoverMarker = this.editor.getDoc().markText(start, end, {
        css: 'text-decoration: underline',
      });
    }

    let tooltipText;
    if (MarkupContent.is(response.contents)) {
      tooltipText = response.contents.value;
    } else if (Array.isArray(response.contents)) {
      const firstItem = response.contents[0];
      if (MarkupContent.is(firstItem)) {
        tooltipText = firstItem.value;
      } else if (firstItem === null) {
        return;
      } else if (typeof firstItem === 'object') {
        tooltipText = firstItem.value;
      } else {
        tooltipText = firstItem;
      }
    } else if (typeof response.contents === 'string') {
      tooltipText = response.contents;
    }

    const htmlElement = document.createElement('div');
    htmlElement.innerText = tooltipText;
    const coords = this.editor.charCoords(start, 'page');
    this._showTooltip(htmlElement, {
github wylieconlon / lsp-editor-adapter / src / codemirror-adapter.ts View on Github external
start = {
        line: response.range.start.line,
        ch: response.range.start.character,
      } as CodeMirror.Position;
      end = {
        line: response.range.end.line,
        ch: response.range.end.character,
      } as CodeMirror.Position;

      this.hoverMarker = this.editor.getDoc().markText(start, end, {
        css: 'text-decoration: underline',
      });
    }

    let tooltipText;
    if (MarkupContent.is(response.contents)) {
      tooltipText = response.contents.value;
    } else if (Array.isArray(response.contents)) {
      const firstItem = response.contents[0];
      if (MarkupContent.is(firstItem)) {
        tooltipText = firstItem.value;
      } else if (firstItem === null) {
        return;
      } else if (typeof firstItem === 'object') {
        tooltipText = firstItem.value;
      } else {
        tooltipText = firstItem;
      }
    } else if (typeof response.contents === 'string') {
      tooltipText = response.contents;
    }