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 opt = vim.opt
local g = vim.g local g = vim.g
local config = require("core.utils").load_config() 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.nvchad_theme = config.ui.theme
g.toggle_theme_icon = "" g.toggle_theme_icon = ""
g.transparency = config.ui.transparency g.transparency = config.ui.transparency
g.theme_switcher_loaded = false g.theme_switcher_loaded = false
-- use filetype.lua instead of filetype.vim. it's enabled by default in neovim 0.8 (nightly) -- 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.did_load_filetypes = 0
g.do_filetype_lua = 1 g.do_filetype_lua = 1
end end

View File

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