]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Make ":<count>LspOutline" work like "outlineWinSize"
authorAndreas Louv <andreas@louv.dk>
Sun, 16 Apr 2023 18:28:42 +0000 (20:28 +0200)
committerAndreas Louv <andreas@louv.dk>
Sun, 16 Apr 2023 19:00:56 +0000 (21:00 +0200)
autoload/lsp/lsp.vim
autoload/lsp/outline.vim
plugin/lsp.vim
test/clangd_tests.vim

index 945ea47851322022af7a2aa77a6ab34b5c6ab398..4b8456b21da59163a22bea9b1a8d57cd2aed0ae8 100644 (file)
@@ -801,8 +801,8 @@ def g:LspRequestDocSymbols()
 enddef
 
 # open a window and display all the symbols in a file (outline)
-export def Outline(cmdmods: string)
-  outline.OpenOutlineWindow(cmdmods)
+export def Outline(cmdmods: string, winsize: number)
+  outline.OpenOutlineWindow(cmdmods, winsize)
   g:LspRequestDocSymbols()
 enddef
 
index b42fe649c19b1852ceaec32dc58b929fc1c179ac..7a337b3c5f6ddb25b09d77624fe404caf858294e 100644 (file)
@@ -218,7 +218,7 @@ def OutlineCleanup()
 enddef
 
 # open the symbol outline window
-export def OpenOutlineWindow(cmdmods: string)
+export def OpenOutlineWindow(cmdmods: string, winsize: number)
   var wid: number = bufwinid('LSP-Outline')
   if wid != -1
     return
@@ -235,7 +235,12 @@ export def OpenOutlineWindow(cmdmods: string)
     endif
   endif
 
-  execute $'{mods} :{opt.lspOptions.outlineWinSize}new LSP-Outline'
+  var size = winsize
+  if size == 0
+    size = opt.lspOptions.outlineWinSize
+  endif
+
+  execute $'{mods} :{size}new LSP-Outline'
   :setlocal modifiable
   :setlocal noreadonly
   :silent! :%d _
index 4abb8b9bade1050c910df7e447ee2ffc348493fb..1e282da4a240efdaca9175b208042a028fddb142 100644 (file)
@@ -78,7 +78,7 @@ command! -nargs=0 -bar LspHighlightClear call LspDocHighlightClear()
 command! -nargs=0 -bar LspHover lsp.Hover(<q-mods>)
 command! -nargs=0 -bar LspIncomingCalls lsp.IncomingCalls()
 command! -nargs=0 -bar LspOutgoingCalls lsp.OutgoingCalls()
-command! -nargs=0 -bar LspOutline lsp.Outline(<q-mods>)
+command! -nargs=0 -bar -count LspOutline lsp.Outline(<q-mods>, <count>)
 command! -nargs=0 -bar LspPeekDeclaration lsp.GotoDeclaration(v:true, <q-mods>)
 command! -nargs=0 -bar LspPeekDefinition lsp.GotoDefinition(v:true, <q-mods>)
 command! -nargs=0 -bar LspPeekImpl lsp.GotoImplementation(v:true, <q-mods>)
index 4fb057bd9bd591dea3f9c095c5c9c0b24096c7cb..f9a5f983943a3a8cc901fac8dddac8d60b7abe4e 100644 (file)
@@ -1191,6 +1191,15 @@ def g:Test_LspOutline()
   execute $':{bnum}bw'
   g:LspOptionsSet({ outlineWinSize: 20 })
 
+  # Validate that <count> works for LspOutline
+  :37LspOutline
+  assert_equal(2, winnr('$'))
+  bnum = winbufnr(winid + 5)
+  assert_equal('LSP-Outline', bufname(bnum))
+  assert_equal(['Function', '  aFunc', '  bFunc'], getbufline(bnum, 4, '$'))
+  assert_equal(37, winwidth(winid + 5))
+  execute $':{bnum}bw'
+
   :%bw!
 enddef