From dd7c1d89037658cb7684e8c4c2ca05af5d117c55 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Wed, 15 Feb 2023 23:59:16 -0500 Subject: [PATCH] add os detect function --- .vimrc | 10 ++++++++++ .vimrc.bundles | 9 ++++++--- coc-nvim-config.vim | 6 ++++++ install.py | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.vimrc b/.vimrc index 28a13c3..9a9fc8f 100644 --- a/.vimrc +++ b/.vimrc @@ -6,6 +6,8 @@ " dotfile location let g:mydotfiles_directory = expand('~/.dotfiles/') let after_directory = g:mydotfiles_directory . 'config/vi-plugs/coc-theme/after/' + + " detect vim type(vim or nvim) if has('nvim') let g:vim_type = 'nvim' let g:vim_version = matchstr(execute('version'), 'NVIM v\zs[^\n]*') @@ -13,6 +15,14 @@ let g:vim_type = 'vim' let g:vim_version = matchstr(execute('version'), 'Vi IMproved \zs[^\n]*') endif + + " detect operating system (Windows/Linux/Darwin) + if has("win64") || has("win32") || has("win16") + let g:os = "Windows" + else + let g:os = substitute(system('uname'), '\n', '', '') + endif + let g:vim_version = str2float(g:vim_version) let g:dotfile_path = '~/.dotfiles/' diff --git a/.vimrc.bundles b/.vimrc.bundles index 3d45ec5..6cb3fd9 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -312,7 +312,7 @@ endfunction endfunction call airline#parts#define_function('bufnum', 'BufferNumber') - let g:airline_extensions = ['bufferline', 'filetype'] + let g:airline_extensions = ['bufferline'] let g:airline_section_x = airline#section#create(['bufnum']) let g:airline_section_y = '' let g:airline_section_z = airline#section#create(['filetype']) @@ -355,7 +355,11 @@ endfunction " - Preview window on the right with 50% width " - CTRL-/ will toggle preview window. - let g:fzf_preview_window = ['right:50%', 'ctrl-/'] + if g:os == 'Windows' + let g:fzf_preview_window = [] + else + let g:fzf_preview_window = ['right:50%', 'ctrl-/'] + end " check if ripgrep is installed @@ -373,7 +377,6 @@ endfunction if HasPlug("coc.nvim") && executable('node') " add desired extensions to the following global variable " coc-clangd: c/c++, may need to install clangd seperatly - let g:coc_global_extensions = ['coc-pyright', 'coc-rls', 'coc-clangd', 'coc-tsserver', 'coc-html', 'coc-cmake', 'coc-json', 'coc-sh', 'coc-java'] if filereadable(g:mydotfiles_directory . "/coc-nvim-config.vim") exec "source " . g:mydotfiles_directory . "/coc-nvim-config.vim" diff --git a/coc-nvim-config.vim b/coc-nvim-config.vim index 5b6e434..4c8916c 100644 --- a/coc-nvim-config.vim +++ b/coc-nvim-config.vim @@ -1,4 +1,10 @@ +" let g:coc_global_extensions = ['coc-pyright', 'coc-rls', 'coc-clangd', 'coc-tsserver', 'coc-html', 'coc-cmake', 'coc-json', 'coc-sh', 'coc-java'] +let g:coc_global_extensions = ['coc-pyright', 'coc-tsserver'] + +g:coc_data_home = g:vim_dir . '/coc' +g:coc_config_home = g:vim_dir . '/coc' + " Use to trigger completion. if has('nvim') inoremap coc#refresh() diff --git a/install.py b/install.py index 689f810..88911d7 100644 --- a/install.py +++ b/install.py @@ -19,7 +19,7 @@ def exist(app): def program_must_exist(app): if not exist(app): - fatal_error(app, "must be installed to continue") + fatal_error("must be installed to continue") def fatal_error(msg): print('Error:', msg)