Skip to content

Commit 6d1ef2e

Browse files
committed
Add documentation
move Global variable to plugin/OmniSharp.vim Create log directory if it doesn't exist
1 parent e872388 commit 6d1ef2e

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

autoload/OmniSharp.vim

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,7 @@ function! OmniSharp#Install(...) abort
431431
let l:location = shellescape(OmniSharp#util#ServerDir())
432432

433433
if has('win32')
434-
if exists('g:OmniSharp_log_dir')
435-
let l:log_dir = g:OmniSharp_log_dir
436-
else
437-
let l:log_dir = s:plugin_root_dir . '\log'
438-
end
439-
let l:logfile = l:log_dir . '\install.log'
434+
let l:logfile = g:OmniSharp_log_dir . '\install.log'
440435
let l:script = shellescape(
441436
\ s:plugin_root_dir . '\installer\omnisharp-manager.ps1')
442437
let l:version_file_location = l:location . '\OmniSharpInstall-version.txt'
@@ -445,11 +440,7 @@ function! OmniSharp#Install(...) abort
445440
\ 'powershell -ExecutionPolicy Bypass -File %s %s -l %s %s',
446441
\ l:script, l:http, l:location, l:version)
447442
else
448-
if exists('g:OmniSharp_log_dir')
449-
let l:log_dir = g:OmniSharp_log_dir
450-
else
451-
let l:log_dir = s:plugin_root_dir . '/log'
452-
end
443+
let l:logfile = g:OmniSharp_log_dir . '/install.log'
453444
let l:logfile = l:log_dir . '/install.log'
454445
let l:script = shellescape(
455446
\ s:plugin_root_dir . '/installer/omnisharp-manager.sh')

autoload/OmniSharp/log.vim

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
let s:save_cpo = &cpoptions
22
set cpoptions&vim
33

4-
if exists('g:OmniSharp_log_dir')
5-
let s:stdiologfile = g:OmniSharp_log_dir . '/stdio.log'
6-
else
7-
let s:stdiologfile = expand('<sfile>:p:h:h:h') . '/log/stdio.log'
8-
end
4+
let s:stdiologfile = g:OmniSharp_log_dir . '/stdio.log'
95

106
" Log from OmniSharp-vim
117
function! OmniSharp#log#Log(job, message, ...) abort

doc/omnisharp-vim.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ to 1, omnisharp-vim will translate the cygwin/WSL unix paths into Windows paths
106106
and back.
107107
Default: 0 >
108108
let g:OmniSharp_translate_cygwin_wsl = 1
109+
<
110+
*g:OmniSharp_log_dir*
111+
Sets the log directory.
112+
113+
Use this option to specify the directory log files will be written to. If the
114+
directory specified does not exist, it will be created. When no log directory is
115+
specified, logs are written to the log directory in the Omnisharp-vim plugin
116+
directory.
117+
Default: /omnisharp-vim/log >
118+
let g:OmniSharp_log_dir = '/omnisharp-vim/log'
109119
<
110120
*g:OmniSharp_loglevel*
111121
Sets the log level.

plugin/OmniSharp.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ let g:OmniSharp_start_without_solution = get(g:, 'OmniSharp_start_without_soluti
3030
" Automatically start server
3131
let g:OmniSharp_start_server = get(g:, 'OmniSharp_start_server', get(g:, 'Omnisharp_start_server', 1))
3232

33+
if has('win32')
34+
let default_log_dir = expand('<sfile>:p:h:h') . '\log'
35+
else
36+
let default_log_dir = expand('<sfile>:p:h:h') . '/log'
37+
end
38+
let g:OmniSharp_log_dir = get(g:, 'OmniSharp_log_dir', default_log_dir)
39+
3340
let defaultlevel = g:OmniSharp_server_stdio ? 'info' : 'warning'
3441
let g:OmniSharp_loglevel = get(g:, 'OmniSharp_loglevel', defaultlevel)
3542

@@ -130,4 +137,9 @@ if g:OmniSharp_selector_ui ==? 'ctrlp'
130137
endif
131138
endif
132139

140+
" Make the log directory if it doesn't exist
141+
if !isdirectory(g:OmniSharp_log_dir)
142+
call mkdir(g:OmniSharp_log_dir, "p")
143+
end
144+
133145
" vim:et:sw=2:sts=2

0 commit comments

Comments
 (0)