Skip to content

Commit

Permalink
vim: Bump up neovim requirement to 0.7.0 or higher (#36)
Browse files Browse the repository at this point in the history
Core lua plugins like lsp, treesitter, telescope, etc. require
neovim 0.7.0 or higher. Neovim 0.5.x or 0.6.x can still run minimally
with this and after versions of dotfiles, but most of lua-based
plugins will be disabled.
  • Loading branch information
wookayin committed Sep 16, 2022
1 parent 7db965a commit 41ed919
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
4 changes: 4 additions & 0 deletions nvim/lua/config/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
-------------
-- See ~/.dotfiles/vim/plugins.vim for the Plug directives

if not pcall(require, 'lspconfig') then
print("Warning: lspconfig not available, skipping configuration.")
return
end
local lspconfig = require('lspconfig')

-- lsp_signature
Expand Down
4 changes: 4 additions & 0 deletions nvim/lua/config/statusline.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
-- Statusline config: lualine.nvim

if not pcall(require, 'lualine') then
print("Warning: lualine not available, skipping configuration.")
return
end

-- From nvim-lualine/lualine.nvim/wiki/Component-snippets
--- @param trunc_width number trunctates component when screen width is less then trunc_width
Expand Down
5 changes: 5 additions & 0 deletions nvim/lua/config/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
---------------
-- @see :help telescope.setup
-- @see https://github.com/nvim-telescope/telescope.nvim#telescope-setup-structure
--
if not pcall(require, 'telescope') then
print("Warning: telescope not available, skipping configuration.")
return
end
local telescope = require("telescope")

if not pcall(require, 'telescope.actions.layout') then
Expand Down
1 change: 1 addition & 0 deletions nvim/lua/config/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-- https://github.com/nvim-treesitter/nvim-treesitter

if not pcall(require, 'nvim-treesitter') then
print("Warning: treesitter not available, skipping configuration.")
return
end

Expand Down
12 changes: 7 additions & 5 deletions vim/plugins.vim
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if has('nvim-0.5.0')
else
Plug 'airblade/vim-gitgutter'
endif
if has('nvim-0.5.0')
if has('nvim-0.7.0')
Plug 'sindrets/diffview.nvim'
endif
if has('nvim-0.4.0') && exists('*nvim_open_win')
Expand Down Expand Up @@ -175,10 +175,12 @@ if has('nvim-0.5.0')
Plug 'nvim-neo-tree/neo-tree.nvim', {'branch': 'main'}
Plug 'MunifTanjim/nui.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', PinIf(!has('nvim-0.6.0'), {'commit': '80cdb00'})
endif
if has('nvim-0.7.0')
Plug 'nvim-telescope/telescope.nvim'
endif

if has('nvim-0.6.1')
if has('nvim-0.7.0')
" Treesitter (see ~/.config/nvim/lua/config/treesitter.lua)
function! TSUpdate(arg) abort
if luaeval('pcall(require, "nvim-treesitter")')
Expand Down Expand Up @@ -208,12 +210,12 @@ endif
" Syntax, Completion, Language Servers, etc.
" ------------------------------------------

let g:dotfiles_completion_backend = has('nvim-0.5.0') ? '@lsp' : ''
let g:dotfiles_completion_backend = has('nvim-0.7.0') ? '@lsp' : ''

" 1. [Neovim 0.5.0 LSP]
" See also for more config: ~/.config/nvim/lua/config/lsp.lua
if g:dotfiles_completion_backend == '@lsp'
Plug 'neovim/nvim-lspconfig', PinIf(!has('nvim-0.7'), {'tag': 'v0.1.3'})
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
Plug 'folke/lua-dev.nvim'

Expand Down
12 changes: 9 additions & 3 deletions vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ endif

" Check neovim version.
if has('nvim') && !has('nvim-0.7.0')
let s:warning_msg = 'Please upgrade to latest neovim (0.7.0+). Support for neovim <= 0.6 will be dropped soon. '
let s:install_command_hint = printf('(Try: %s install neovim)', has('mac') ? 'brew' : 'dotfiles')
autocmd VimEnter * echohl WarningMsg | echom s:warning_msg . s:install_command_hint | echohl None
let s:warning_msg = 'Please upgrade to latest neovim (0.7.0+). Support for neovim < 0.7 will be dropped soon. '
let s:warning_msg .= printf('(Try: %s install neovim)', has('mac') ? 'brew' : 'dotfiles')
if exists('*luaeval')
autocmd VimEnter * call timer_start(100, { ->
\ luaeval("vim.notify(_A[1], _A[2], _A[3])", [s:warning_msg, 'error', {'title': 'Deprecation Warning'}])
\ })
else
autocmd VimEnter * echohl WarningMsg | echom s:warning_msg | echohl None
endif
endif

"""""""""""""""""""""""""""""""""""""""""
Expand Down

0 comments on commit 41ed919

Please sign in to comment.