diff options
| author | jdhao <jdhao@hotmail.com> | 2022-05-15 21:16:02 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2022-05-15 21:16:02 +0800 |
| commit | 4899a82b350dcaafc54623911788adc8afec7eec (patch) | |
| tree | 8938dad27e02978369a1f3633630f8e165b677f6 /lua/config | |
| parent | 424981683efee76384480c68df4452269992bf78 (diff) | |
refactor: local fn = vim.fn
Diffstat (limited to 'lua/config')
| -rw-r--r-- | lua/config/lsp.lua | 13 | ||||
| -rw-r--r-- | lua/config/statusline.lua | 14 |
2 files changed, 15 insertions, 12 deletions
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 9ead5e5..b5fab6a 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -1,3 +1,4 @@ +local fn = vim.fn local api = vim.api local lsp = vim.lsp @@ -135,9 +136,9 @@ if utils.executable('bash-language-server') then }) end -local sumneko_binary_path = vim.fn.exepath("lua-language-server") +local sumneko_binary_path = fn.exepath("lua-language-server") 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 = fn.fnamemodify(sumneko_binary_path, ":h:h:h") local runtime_path = vim.split(package.path, ";") table.insert(runtime_path, "lua/?.lua") @@ -173,10 +174,10 @@ if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then end -- Change diagnostic signs. -vim.fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" }) -vim.fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" }) -vim.fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" }) -vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) +fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" }) +fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" }) +fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" }) +fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) -- global config for diagnostic vim.diagnostic.config({ diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua index 85e6e46..ff69060 100644 --- a/lua/config/statusline.lua +++ b/lua/config/statusline.lua @@ -1,3 +1,5 @@ +local fn = vim.fn + local function spell() if vim.o.spell then return string.format("[SPELL]") @@ -9,7 +11,7 @@ end local function ime_state() if vim.g.is_mac then -- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11 - local layout = vim.fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '') + local layout = fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '') if layout == '0' then return '[CN]' end @@ -35,20 +37,20 @@ end local function mixed_indent() local space_pat = [[\v^ +]] local tab_pat = [[\v^\t+]] - local space_indent = vim.fn.search(space_pat, 'nwc') - local tab_indent = vim.fn.search(tab_pat, 'nwc') + local space_indent = fn.search(space_pat, 'nwc') + local tab_indent = fn.search(tab_pat, 'nwc') local mixed = (space_indent > 0 and tab_indent > 0) local mixed_same_line if not mixed then - mixed_same_line = vim.fn.search([[\v^(\t+ | +\t)]], 'nwc') + mixed_same_line = fn.search([[\v^(\t+ | +\t)]], 'nwc') mixed = mixed_same_line > 0 end if not mixed then return '' end if mixed_same_line ~= nil and mixed_same_line > 0 then return 'MI:'..mixed_same_line end - local space_indent_cnt = vim.fn.searchcount({pattern=space_pat, max_count=1e3}).total - local tab_indent_cnt = vim.fn.searchcount({pattern=tab_pat, max_count=1e3}).total + local space_indent_cnt = fn.searchcount({pattern=space_pat, max_count=1e3}).total + local tab_indent_cnt = fn.searchcount({pattern=tab_pat, max_count=1e3}).total if space_indent_cnt > tab_indent_cnt then return 'MI:'..tab_indent else |
