Git Product home page Git Product logo

ddu-source-lsp's Introduction

ddu-source-lsp

Ddu source for lsp.

Supported lsp clients are:

Supported methods are:

  • textDocument/declaration
  • textDocument/definition
  • textDocument/typeDefinition
  • textDocument/implementation
  • textDocument/references
  • textDocument/documentSymbol
  • workspace/symbol
  • callHierarchy/incomingCalls
  • callHierarchy/outgoingCalls
  • typeHierarchy/supertypes
  • typeHierarchy/subtypes
  • textDocument/codeAction

See doc for details.

ddu-source-lsp_diagnostic

Ddu source for diagnostic.

Supported lsp clients are:

See doc for details.

ddu-source-lsp's People

Contributors

arrow2nd avatar kamecha avatar kuuote avatar ogaken-1 avatar uga-rosa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ddu-source-lsp's Issues

When using with intelephense(PHP), It looks not working enough.

Thank you for the nice plugin.

When running "lsp_documentSymbol", There are only Namespace and Class name, no methods.

Screen shot

"lsp_definition" is looks working smooth. And when using with Rust, It looks working.
Can I fix this issue by the settings?

Screen shot

This is my settings. below:

let line = &lines - 4
let column = &columns - 4
let win_border = 'rounded'
let win_height = float2nr(line * 0.8)
let win_width = float2nr(column * 0.8)
let win_col = float2nr((column - win_width) / 2)
let win_row = float2nr(win_height / 2) 
let preview_height = line - win_height - 1
let preview_width = win_width
let preview_col = win_col
let preview_row = float2nr(preview_height / 2)

call ddu#custom#patch_global({
\	'ui': 'ff',
\	'uiParams': {
\		'ff': {
\			'ignoreEmpty': v:true,
\			'split': 'floating',
\			'startAutoAction': v:true,
\			'autoAction': { 'name': 'preview', 'delay': 0, },
\			'prompt': '> ',
\			'startFilter': v:true,
\			'filterSplitDirection': 'floating',
\			'filterFloatingPosition': 'bottom',
\			'floatingBorder': win_border,
\			'winHeight': win_height,
\			'winWidth': win_width,
\			'winRow': win_row,
\			'winCol': win_col,
\			'previewFloating': v:true,
\			'previewFloatingBorder': win_border,
\			'previewHeight': preview_height,
\			'previewWidth': preview_width,
\			'previewRow': preview_row,
\			'previewCol': preview_col,
\		},
\		'filer': {
\			'split': 'floating',
\			'floatingBorder': win_border,
\			'winHeight': win_height,
\			'winWidth': win_width,
\			'winRow': win_row,
\			'winCol': win_col,
\			'previewFloating': v:true,
\			'previewFloatingBorder': win_border,
\			'previewHeight': preview_height,
\			'previewWidth': preview_width,
\			'previewRow': preview_row,
\			'previewCol': preview_col,
\		},
\	},
\	'sourceOptions': {
\		'_': {
\			'matchers': ['matcher_fzf'],
\			'sorters': ['sorter_fzf'],
\			'ignoreCase': v:true,
\		},
\		'file': {
\			'columns': ['icon_filename'],
\		},
\		'line': {
\			'sorters': [],
\		},
\	},
\	'filterParams': {
\		'matcher_fzf': {
\			'highlightMatched': 'Search',
\		},
\	},
\	'kindOptions': {
\		'file': {
\			'defaultAction': 'open',
\		},
\		'word': {
\			'defaultAction': 'append',
\		},
\		'lsp': {
\			'defaultAction': 'open',
\		},
\		'lsp_codeAction': {
\			'defaultAction': 'apply',
\		},
\	},
\	'actionOptions': {
\		'narrow': {
\			'quit': v:true,
\		},
\	},
\})

call ddu#custom#patch_local('file_rec', {
\	'sources': [{
\		'name':'file_rec',
\		'params': {
\			'ignoredDirectories': ['.git', 'var', 'node_modules', ]
\		},
\	}],
\})

call ddu#custom#patch_local('grep', {
\	'sourceParams' : {
\		'rg' : {
\			'args': ['--column', '--no-heading', '--color', 'never', '-i'],
\		},
\	 },
\	'uiParams': {
\		'ff': {
\			'startFilter': v:false,
\		 }
\	 },
\	'resume': v:true,
\ })

call ddu#custom#patch_local('lsp_documentSymbol', {
\	'sources': [{
\		'name':'lsp_documentSymbol',
\		'params': {
\			'clientName': 'vim-lsp',
\		},
\	}],
\	'sourceOptions': {
\		'lsp': {
\			'volatile': v:true,
\		},
\	},
\	'uiParams': {
\		'ff': {
\			'ignoreEmpty': v:false,
\		},
\	},
\})

call ddu#custom#patch_local('lsp_definition', {
\	'sources': [{
\		'name':'lsp_definition',
\		'params': {
\			'clientName': 'vim-lsp',
\		},
\	}],
\	'uiParams': {
\		'ff': {
\			'immediateAction': 'open',
\		},
\	},
\})

nnoremap <Leader>b <Cmd>Ddu buffer -ui-param-ff-startFilter=v:false<CR>
nnoremap <Leader>o <Cmd>Ddu line<CR>
nnoremap <Leader>r <Cmd>Ddu register -ui-param-ff-startFilter=v:false<CR>
nnoremap <Leader>f <Cmd>Ddu -name=file_rec<CR>

nnoremap <Leader>g <Cmd>Ddu rg -name=grep -source-param-rg-input='`'Pattern: '->input('<cword>'->expand())`'<CR>
nnoremap <C-g> <Cmd>Ddu -name=grep<CR>
nnoremap <C-n> <Cmd>call ddu#ui#multi_actions(['cursorNext', 'itemAction'], 'grep')<CR>
nnoremap <C-p> <Cmd>call ddu#ui#multi_actions(['cursorPrevious', 'itemAction'], 'grep')<CR>

nnoremap <Leader>ls <Cmd>Ddu -name=lsp_documentSymbol<CR>
nnoremap <Leader>lj <Cmd>Ddu -name=lsp_definition<CR>

"--------------------
" FF
"--------------------
autocmd FileType ddu-ff call s:ddu_ff_settings()
function! s:ddu_ff_settings() abort
	nnoremap <buffer><silent> <CR> <Cmd>call ddu#ui#do_action('itemAction')<CR>
	nnoremap <buffer><silent> s <Cmd>call ddu#ui#do_action('toggleSelectItem')<CR>
	nnoremap <buffer><silent> i <Cmd>call ddu#ui#do_action('openFilterWindow')<CR>
	nnoremap <buffer><silent> q <Cmd>call ddu#ui#do_action('quit')<CR>
	nnoremap <buffer><silent> <C-g> <Cmd>call ddu#ui#do_action('quit')<CR>
endfunction
autocmd FileType ddu-ff-filter call s:ddu_filter_my_settings()
function! s:ddu_filter_my_settings() abort
	inoremap <buffer> <C-n> <Nop>
	inoremap <buffer> <C-p> <Nop>
	nnoremap <buffer> <CR> :q<CR>
	nnoremap <buffer> q :q<CR>
	inoremap <buffer> <CR> <ESC>:q<CR>
	inoremap <buffer> jj <ESC>:q<CR>
	inoremap <buffer> jk <ESC>:q<CR>
	inoremap <buffer> kj <ESC>:q<CR>
	inoremap <buffer> kk <ESC>:q<CR>
endfunction

Cannot gether candidate by lsp_definition with vim-lsp

Environment

  • NVIM v0.10.0-dev-1249+gdc6d0d2da-Homebrew
  • vim-lsp(up to date version)
  • LSP(intelephense)

Description

Cannot gather candidate by lsp_definition with vim-lsp.
But enable gather canddidate by lsp_documentSymbol.

slack URL

https://vim-jp.slack.com/archives/CLKR04BEF/p1699429772613499

minimal vimrc

if &compatible
  set nocompatible               " Be iMproved
endif

if empty(glob('~/.config/nvim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
       \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall | source $MYVIMRC
endif

call plug#begin('~/.config/nvim/plugged')
Plug 'vim-denops/denops.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'Shougo/ddu.vim'
Plug 'Shougo/ddu-ui-ff'
Plug 'Shougo/ddu-kind-file'
Plug 'Shougo/ddu-filter-matcher_substring'
Plug 'uga-rosa/ddu-source-lsp'
call plug#end()

call ddu#custom#patch_global(#{
			\   ui: 'ff',
			\ })

call ddu#custom#paaatch_global(#{
			\   kindOptions: #{
			\     file: #{
			\       defaultAction: 'open',
			\     },
			\   }
			\ })

call ddu#custom#patch_global(#{
			\   sourceOptions: #{
			\     _: #{
			\       matchers: ['matcher_substring'],
			\     },
			\   }
			\ })

let g:ddu_source_lsp_clientName = 'vim-lsp'
call ddu#custom#patch_global(#{
      \ kindOptions: #{
      \   lsp: #{
      \     defaultAction: 'open',
      \   },
      \   lsp_codeAction: #{
      \     defaultAction: 'apply',
      \   },
      \ },
      \})

nnoremap <silent> O 
    \ <Cmd>call ddu#start(#{
    \ sync: v:true,
    \ sources: [#{
    \   name: 'lsp_documentSymbol',
    \ }],
    \ uiParams: #{
    \   ff: #{
    \     immediateAction: 'open',
    \   },
    \ }
    \})<CR>

Reproduce process

  1. Open neovim
  2. execute :PlugUpdate<CR>
  3. Open code(see example)
  4. Type O aaaa

example

<?php

class A
{
    public function __construct()
    {
    }

    /**
     * @return string
     */
    public function aaa()
    {
        return 'ok';
    }

    public function bbb()
    {
        return 'no';
    }
}

$obj = new A();

Preview action with fails at code action result is empty.

Problem

Preview action with lsp_codeAction fails at code action result is empty.

TypeError: Cannot read properties of undefined (reading 'slice')
    at file:///tmp/dein/cache/nvim/.cache/init.vim/.dein/denops/@ddu-kinds/lsp_codeAction.ts:502:41
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async Object.forEach (<https://deno.land/x/[email protected]/lib/wrap_async_iterator.ts:175:9>)
    at async applyTextEditToLines (file:///tmp/dein/cache/nvim/.cache/init.vim/.dein/denops/@ddu-kinds/lsp_codeAction.ts:492:3)
    at async createPatchFromTextEdit (file:///tmp/dein/cache/nvim/.cache/init.vim/.dein/denops/@ddu-kinds/lsp_codeAction.ts:451:20)
    at async createPatchFromTextDocumentEdit (file:///tmp/dein/cache/nvim/.cache/init.vim/.dein/denops/@ddu-kinds/lsp_codeAction.ts:438:10)
    at async file:///tmp/dein/cache/nvim/.cache/init.vim/.dein/denops/@ddu-kinds/lsp_codeAction.ts:126:22
    at async <https://deno.land/x/[email protected]/lib/wrap_async_iterator.ts:60:17>
    at async Object.reduce (<https://deno.land/x/[email protected]/lib/wrap_async_iterator.ts:158:24>)
    at async Kind.getPreviewer (file:///tmp/dein/cache/nvim/.cache/init.vim/.dein/denops/@ddu-kinds/lsp_codeAction.ts:123:23)

To Reproduce

Environment
NVIM v0.10.0-dev-533+g7e301ed5b-dirty
deno 1.34.3 (release, x86_64-unknown-linux-gnu)
set rtp+=path/to/Shougo/ddu-ui-ff
set rtp+=path/to/neovim/nvim-lspconfig
set rtp+=path/to/Shougo/ddu.vim
set rtp+=path/to/uga-rosa/ddu-source-lsp
set rtp+=path/to/vim-denops/denops.vim

lua << EOS

require('lspconfig').denols.setup {}

vim.keymap.set('n', 'p', '<Cmd>call ddu#ui#do_action("preview")<CR>')
vim.keymap.set('n', '<CR>', '<Cmd>call ddu#ui#do_action("itemAction")<CR>')
vim.keymap.set('n', '<C-a>', function()
  vim.fn['ddu#start'] {
    sources = { {
      name = 'lsp_codeAction',
    } },
    kindOptions = {
      lsp_codeAction = {
        defaultAction = 'apply',
      },
    },
    ui = 'ff',
  }
end)

EOS
  • Launch Neovim with above init.vim
  • Edit xxx.ts to function hoge() {}
  • Launch ddu <C-a>
  • Point cursor to Remove unused declaration or Move to a new file
  • Do preview action p

Bugs: documentSymbol items via expandItem does not work

lsp_callHierachy item support ddu's tree item and expandItem action.

However lsp_documnetSymbol item support only ddu's tree item. it seems not support expandItem.

when I fire expandItem action on lsp_documnetSymbol, all item is expanded regardless of it's parent item.

So lsp_documnetSymbol should consider args.parent like lsp_callHierachy bellow. I think.

if (args.parent) {
// called from expandItem
if (
is.ObjectOf({ data: is.ObjectOf({ children: is.Array }) })(
args.parent,
)
) {
const children = args.parent.data.children as ItemHierarchy[];
const resolvedChildren = await Promise.all(children.map(peek));
controller.enqueue(resolvedChildren);
}
} else {

Print error when it is not under LSP files

[denops] Failed to handle message 2,invoke,dispatch,ddu,start,[object Object] 0,function denops#api#eval, line 2: Vim(return):E5108: Error executing lua ...ub.
com/uga-rosa/ddu-source-nvim_lsp/lua/ddu_nvim_lsp.lua:36: bad argument #1 to 'pairs' (table expected, got nil)
[denops] stack traceback:
[denops]     [C]: in function 'pairs'
[denops]     ...ub.com/uga-rosa/ddu-source-nvim_lsp/lua/ddu_nvim_lsp.lua:36: in function 'request'
[denops]     [string "luaeval()"]:1: in main chunk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.