store vim version in global for v0.8 compatibility checks

so we dont have to run vim.version() function in many places of the config cuz we will be making nvchad 0.8 compatible too bit by bit
This commit is contained in:
siduck 2022-07-26 13:05:58 +00:00
parent 8eb56b6644
commit 429ce94da1
2 changed files with 3 additions and 5 deletions

View file

@ -1,15 +1,15 @@
local opt = vim.opt
local g = vim.g
local config = require("core.utils").load_config()
local vim_version = vim.version()
g.vim_version = vim.version().minor
g.nvchad_theme = config.ui.theme
g.toggle_theme_icon = ""
g.transparency = config.ui.transparency
g.theme_switcher_loaded = false
-- use filetype.lua instead of filetype.vim. it's enabled by default in neovim 0.8 (nightly)
if vim_version.minor < 8 then
if g.vim_version < 8 then
g.did_load_filetypes = 0
g.do_filetype_lua = 1
end

View file

@ -13,9 +13,7 @@ local utils = require "core.utils"
-- export on_attach & capabilities for custom lspconfigs
M.on_attach = function(client, bufnr)
local vim_version = vim.version()
if vim_version.minor > 7 then
if vim.g.vim_version > 7 then
-- nightly
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false