Cleanup handle documentSymbol response.
@@ -388,10 +388,8 @@ class LanguageClient:
uri, cb = self.getArgs(args, ["uri", "cb"])
if cb is None:
- if self.nvim.eval("get(g:, 'loaded_fzf', 0)") == 1:
- cb = self.handleTextDocumentDocumentSymbolResponse
- else:
- logger.warn("FZF not loaded.")
+ cb = partial(self.handleTextDocumentDocumentSymbolResponse,
+ selectionUI=self.getSelectionUI())
self.rpc.call('textDocument/documentSymbol', {
"textDocument": {
@@ -399,6 +397,11 @@ class LanguageClient:
}
}, cb)
+ def getSelectionUI(self) -> str:
+ if self.nvim.eval("get(g:, 'loaded_fzf', 0)") == 1:
+ return "fzf"
+ return ""
+
def fzf(self, source: List, sink: str) -> None:
self.asyncCommand("""
call fzf#run(fzf#wrap({{
@@ -408,7 +411,9 @@ call fzf#run(fzf#wrap({{
""".replace("\n", "").format(json.dumps(source), sink))
self.nvim.async_call(lambda: self.nvim.feedkeys("i"))
- def handleTextDocumentDocumentSymbolResponse(self, symbols: List) -> None:
+ def handleTextDocumentDocumentSymbolResponse(
+ self, symbols: List, selectionUI: str) -> None:
+ if selectionUI == "fzf":
source = []
for sb in symbols:
name = sb["name"]
@@ -417,7 +422,13 @@ call fzf#run(fzf#wrap({{
character = start["character"] + 1
entry = "{}:{}:\t{}".format(line, character, name)
source.append(entry)
- self.fzf(source, "LanguageClient#FZFSinkTextDocumentDocumentSymbol")
+ self.fzf(source,
+ "LanguageClient#FZFSinkTextDocumentDocumentSymbol")
+ else:
+ msg = "No selection UI found. Consider install fzf or denite.vim."
+ self.asyncEcho(msg)
+ logger.warn(msg)
+
logger.info('End textDocument/documentSymbol')
@neovim.function('LanguageClient_FZFSinkTextDocumentDocumentSymbol')
