]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add <mods> to ":LspOutline"
authorAndreas Louv <andreas@louv.dk>
Sun, 16 Apr 2023 07:40:12 +0000 (09:40 +0200)
committerAndreas Louv <andreas@louv.dk>
Sun, 16 Apr 2023 12:21:02 +0000 (14:21 +0200)
This will allow you to add command modifiers to the created Outline
window. The option "outlineOnRight" is still respected but can be
overridden by explicitly setting another modifier.

autoload/lsp/lsp.vim
autoload/lsp/outline.vim
plugin/lsp.vim

index 7c86f8f43486d7556f7b8ee5d9e43b24b6854c86..3f364bdb43a01662b6f5529706002153a4f7b732 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()
-  outline.OpenOutlineWindow()
+export def Outline(cmdmods: string)
+  outline.OpenOutlineWindow(cmdmods)
   g:LspRequestDocSymbols()
 enddef
 
index 266fc55db0daa7228ad7021b8614edc6444989de..eb91ea1e248e606fd9d49b1e2b6e653b3d31b6fc 100644 (file)
@@ -218,7 +218,7 @@ def OutlineCleanup()
 enddef
 
 # open the symbol outline window
-export def OpenOutlineWindow()
+export def OpenOutlineWindow(cmdmods: string)
   var wid: number = bufwinid('LSP-Outline')
   if wid != -1
     return
@@ -226,11 +226,16 @@ export def OpenOutlineWindow()
 
   var prevWinID: number = win_getid()
 
-  if opt.lspOptions.outlineOnRight
-    execute $':botright :{opt.lspOptions.outlineWinSize}vnew LSP-Outline'
-  else
-    execute $':topleft :{opt.lspOptions.outlineWinSize}vnew LSP-Outline'
+  var mods = cmdmods
+  if mods == ''
+    if opt.lspOptions.outlineOnRight
+      mods = ':botright'
+    else
+      mods = ':topleft'
+    endif
   endif
+
+  execute $'{mods} :{opt.lspOptions.outlineWinSize}vnew LSP-Outline'
   :setlocal modifiable
   :setlocal noreadonly
   :silent! :%d _
index 3aaf2014ca59cf1e046ecf6d19a9b6c558bad2f5..cc2a4962609be5a91ebbc48345f708de5ad96e9b 100644 (file)
@@ -78,7 +78,7 @@ command! -nargs=0 -bar LspHighlightClear call LspDocHighlightClear()
 command! -nargs=0 -bar LspHover lsp.Hover()
 command! -nargs=0 -bar LspIncomingCalls lsp.IncomingCalls()
 command! -nargs=0 -bar LspOutgoingCalls lsp.OutgoingCalls()
-command! -nargs=0 -bar LspOutline lsp.Outline()
+command! -nargs=0 -bar LspOutline lsp.Outline(<q-mods>)
 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>)