mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Use proper true or false value for boolean variables
In lua, 0 and empty string is true, which is counter-intuitive and different from vim script. So we need to use proper boolean type for vim script global variables, instead of numbers.
This commit is contained in:
parent
42d3c49fea
commit
07c80f948d
@ -1,9 +1,9 @@
|
|||||||
"{ Global Variable
|
"{ Global Variable
|
||||||
|
|
||||||
"{{ Custom variables
|
"{{ Custom variables
|
||||||
let g:is_win = has('win32') || has('win64')
|
let g:is_win = (has('win32') || has('win64')) ? v:true : v:false
|
||||||
let g:is_linux = has('unix') && !has('macunix')
|
let g:is_linux = (has('unix') && !has('macunix')) ? v:true : v:false
|
||||||
let g:is_mac = has('macunix')
|
let g:is_mac = has('macunix') ? v:true : v:false
|
||||||
"}}
|
"}}
|
||||||
|
|
||||||
"{{ Builtin variables
|
"{{ Builtin variables
|
||||||
|
|||||||
@ -109,7 +109,7 @@ lspconfig.vimls.setup{
|
|||||||
}
|
}
|
||||||
|
|
||||||
local sumneko_binary_path = vim.fn.exepath('lua-language-server')
|
local sumneko_binary_path = vim.fn.exepath('lua-language-server')
|
||||||
if vim.g.is_mac > 0 or vim.g.is_linux > 0 and sumneko_binary_path ~= '' then
|
if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= '' then
|
||||||
local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ':h:h:h')
|
local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ':h:h:h')
|
||||||
|
|
||||||
local runtime_path = vim.split(package.path, ';')
|
local runtime_path = vim.split(package.path, ';')
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
|
local utils = require('utils')
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
|
|
||||||
local packer_install_dir = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
|
local packer_install_dir = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
|
||||||
|
|
||||||
local plug_url_format = ''
|
local plug_url_format = ''
|
||||||
if vim.g.is_linux > 0 then
|
if vim.g.is_linux then
|
||||||
plug_url_format = 'https://hub.fastgit.org/%s'
|
plug_url_format = 'https://hub.fastgit.org/%s'
|
||||||
else
|
else
|
||||||
plug_url_format = 'https://github.com/%s'
|
plug_url_format = 'https://github.com/%s'
|
||||||
@ -32,12 +33,12 @@ require('packer').startup(
|
|||||||
-- auto-completion engine
|
-- auto-completion engine
|
||||||
use { 'hrsh7th/nvim-compe', event = 'InsertEnter *', config = [[require('config.compe')]] }
|
use { 'hrsh7th/nvim-compe', event = 'InsertEnter *', config = [[require('config.compe')]] }
|
||||||
|
|
||||||
if (vim.g.is_mac > 0) or (vim.g.is_linux > 0) then
|
if vim.g.is_mac or vim.g.is_linux then
|
||||||
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', config = [[require('config.treesitter')]]}
|
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', config = [[require('config.treesitter')]]}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Python syntax highlighting and more
|
-- Python syntax highlighting and more
|
||||||
if vim.g.is_win == 1 then
|
if vim.g.is_win then
|
||||||
use {'numirias/semshi', ft = 'python', config = 'vim.cmd [[UpdateRemotePlugins]]'}
|
use {'numirias/semshi', ft = 'python', config = 'vim.cmd [[UpdateRemotePlugins]]'}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -48,8 +49,9 @@ require('packer').startup(
|
|||||||
use {'jeetsukumaran/vim-pythonsense', ft = {'python'}}
|
use {'jeetsukumaran/vim-pythonsense', ft = {'python'}}
|
||||||
|
|
||||||
use 'machakann/vim-swap'
|
use 'machakann/vim-swap'
|
||||||
|
|
||||||
-- IDE for Lisp
|
-- IDE for Lisp
|
||||||
if fn.executable('sbcl') > 0 then
|
if utils.executable('sbcl') then
|
||||||
-- use 'kovisoft/slimv'
|
-- use 'kovisoft/slimv'
|
||||||
use {'vlime/vlime', rtp = 'vim/', ft={'lisp', }}
|
use {'vlime/vlime', rtp = 'vim/', ft={'lisp', }}
|
||||||
end
|
end
|
||||||
@ -70,7 +72,7 @@ require('packer').startup(
|
|||||||
use 'haya14busa/vim-asterisk'
|
use 'haya14busa/vim-asterisk'
|
||||||
|
|
||||||
-- File search, tag search and more
|
-- File search, tag search and more
|
||||||
if vim.g.is_win == 1 then
|
if vim.g.is_win then
|
||||||
use 'Yggdroot/LeaderF'
|
use 'Yggdroot/LeaderF'
|
||||||
else
|
else
|
||||||
use {'Yggdroot/LeaderF', run = ':LeaderfInstallCExtension'}
|
use {'Yggdroot/LeaderF', run = ':LeaderfInstallCExtension'}
|
||||||
@ -114,13 +116,13 @@ require('packer').startup(
|
|||||||
|
|
||||||
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may
|
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may
|
||||||
-- not be possible since we maybe in a server which disables GUI.
|
-- not be possible since we maybe in a server which disables GUI.
|
||||||
if (vim.g.is_win == 1) or (vim.g.is_mac == 1) then
|
if vim.g.is_win or vim.g.is_mac then
|
||||||
-- open URL in browser
|
-- open URL in browser
|
||||||
use 'tyru/open-browser.vim'
|
use 'tyru/open-browser.vim'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Only install these plugins if ctags are installed on the system
|
-- Only install these plugins if ctags are installed on the system
|
||||||
if fn.executable('ctags') > 0 then
|
if utils.executable('ctags') then
|
||||||
-- plugin to manage your tags
|
-- plugin to manage your tags
|
||||||
use 'ludovicchabant/vim-gutentags'
|
use 'ludovicchabant/vim-gutentags'
|
||||||
-- show file tags in vim window
|
-- show file tags in vim window
|
||||||
@ -147,7 +149,7 @@ require('packer').startup(
|
|||||||
use 'simnalamburt/vim-mundo'
|
use 'simnalamburt/vim-mundo'
|
||||||
|
|
||||||
-- Manage your yank history
|
-- Manage your yank history
|
||||||
if (vim.g.is_win == 1) or (vim.g.is_mac == 1) then
|
if vim.g.is_win or vim.g.is_mac then
|
||||||
use 'svermeulen/vim-yoink'
|
use 'svermeulen/vim-yoink'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -161,9 +163,9 @@ require('packer').startup(
|
|||||||
-- Plug 'junegunn/vim-peekaboo'
|
-- Plug 'junegunn/vim-peekaboo'
|
||||||
use {'jdhao/better-escape.vim', event = {'InsertEnter', }}
|
use {'jdhao/better-escape.vim', event = {'InsertEnter', }}
|
||||||
|
|
||||||
if vim.g.is_mac == 1 then
|
if vim.g.is_mac then
|
||||||
use {'lyokha/vim-xkbswitch', event = {'InsertEnter', }}
|
use {'lyokha/vim-xkbswitch', event = {'InsertEnter', }}
|
||||||
elseif vim.g.is_win == 1 then
|
elseif vim.g.is_win then
|
||||||
use {'Neur1n/neuims', event = {'InsertEnter', }}
|
use {'Neur1n/neuims', event = {'InsertEnter', }}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -203,11 +205,11 @@ require('packer').startup(
|
|||||||
use {'elzr/vim-json', ft = {'json', 'markdown'}}
|
use {'elzr/vim-json', ft = {'json', 'markdown'}}
|
||||||
|
|
||||||
-- Markdown previewing (only for Mac and Windows)
|
-- Markdown previewing (only for Mac and Windows)
|
||||||
if (vim.g.is_win == 1) or (vim.g.is_mac == 1) then
|
if vim.g.is_win or vim.g.is_mac then
|
||||||
use {'iamcco/markdown-preview.nvim', run = function() fn['mkdp#util#install']() end, ft = {'markdown'}}
|
use {'iamcco/markdown-preview.nvim', run = function() fn['mkdp#util#install']() end, ft = {'markdown'}}
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.g.is_mac == 1 then
|
if vim.g.is_mac then
|
||||||
use {'rhysd/vim-grammarous', ft = {'markdown', }}
|
use {'rhysd/vim-grammarous', ft = {'markdown', }}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -225,7 +227,7 @@ require('packer').startup(
|
|||||||
use 'michaeljsmith/vim-indent-object'
|
use 'michaeljsmith/vim-indent-object'
|
||||||
|
|
||||||
-- Only use these plugin on Windows and Mac and when LaTeX is installed
|
-- Only use these plugin on Windows and Mac and when LaTeX is installed
|
||||||
if ( vim.g.is_win == 1 or vim.g.is_mac ==1 ) and fn.executable('latex') > 0 then
|
if vim.g.is_win or vim.g.is_mac and utils.executable('latex') then
|
||||||
-- vimtex use autoload feature of Vim, so it is not necessary to use `for`
|
-- vimtex use autoload feature of Vim, so it is not necessary to use `for`
|
||||||
-- keyword of vim-plug to try to lazy-load it,
|
-- keyword of vim-plug to try to lazy-load it,
|
||||||
-- see https://github.com/junegunn/vim-plug/issues/785
|
-- see https://github.com/junegunn/vim-plug/issues/785
|
||||||
@ -237,7 +239,7 @@ require('packer').startup(
|
|||||||
|
|
||||||
-- Since tmux is only available on Linux and Mac, we only enable these plugins
|
-- Since tmux is only available on Linux and Mac, we only enable these plugins
|
||||||
-- for Linux and Mac
|
-- for Linux and Mac
|
||||||
if fn.executable('tmux') > 0 then
|
if utils.executable('tmux') then
|
||||||
-- .tmux.conf syntax highlighting and setting check
|
-- .tmux.conf syntax highlighting and setting check
|
||||||
use {'tmux-plugins/vim-tmux', ft = {'tmux', }}
|
use {'tmux-plugins/vim-tmux', ft = {'tmux', }}
|
||||||
end
|
end
|
||||||
@ -257,12 +259,12 @@ require('packer').startup(
|
|||||||
use {'cespare/vim-toml', ft = {'toml',}}
|
use {'cespare/vim-toml', ft = {'toml',}}
|
||||||
|
|
||||||
-- Edit text area in browser using nvim
|
-- Edit text area in browser using nvim
|
||||||
if (vim.g.is_win == 1) or (vim.g.is_mac == 1) then
|
if vim.g.is_win or vim.g.is_mac then
|
||||||
use {'glacambre/firenvim', run = function() fn['firenvim#install'](0) end}
|
use {'glacambre/firenvim', run = function() fn['firenvim#install'](0) end}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debugger plugin
|
-- Debugger plugin
|
||||||
if (vim.g.is_win == 1) or (vim.g.is_linux == 1) then
|
if vim.g.is_win or vim.g.is_linux then
|
||||||
use {'sakhnik/nvim-gdb', run = {'bash install.sh'}}
|
use {'sakhnik/nvim-gdb', run = {'bash install.sh'}}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -272,7 +274,7 @@ require('packer').startup(
|
|||||||
-- Calculate statistics for visual selection
|
-- Calculate statistics for visual selection
|
||||||
use 'wgurecky/vimSum'
|
use 'wgurecky/vimSum'
|
||||||
|
|
||||||
if vim.g.is_linux == 1 then
|
if vim.g.is_linux then
|
||||||
use 'ojroques/vim-oscyank'
|
use 'ojroques/vim-oscyank'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -3,3 +3,15 @@
|
|||||||
function inspect(item)
|
function inspect(item)
|
||||||
print(vim.inspect(item))
|
print(vim.inspect(item))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.executable(name)
|
||||||
|
if vim.fn.executable(name) > 0 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user