From ac5a50894b77c3ac33102a9f7410de63de3dd5a2 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Sat, 10 Feb 2024 15:42:23 +0100 Subject: [PATCH] vim: make initialization structure more consistent --- config/nvim/lua/fschauen/colorscheme.lua | 12 ++++ config/nvim/lua/fschauen/filetype.lua | 15 +++++ config/nvim/lua/fschauen/init.lua | 73 +----------------------- config/nvim/lua/fschauen/lazy.lua | 53 +++++++++++++++++ 4 files changed, 83 insertions(+), 70 deletions(-) create mode 100644 config/nvim/lua/fschauen/colorscheme.lua create mode 100644 config/nvim/lua/fschauen/filetype.lua create mode 100644 config/nvim/lua/fschauen/lazy.lua diff --git a/config/nvim/lua/fschauen/colorscheme.lua b/config/nvim/lua/fschauen/colorscheme.lua new file mode 100644 index 0000000..37e7467 --- /dev/null +++ b/config/nvim/lua/fschauen/colorscheme.lua @@ -0,0 +1,12 @@ +local M = {} + +M.setup = function() + local colorscheme = 'gruvbox' + vim.cmd('silent! colorscheme ' .. colorscheme) + if vim.v.errmsg ~= '' then + vim.notify(('Colorscheme %s not found!'):format(colorscheme), vim.log.levels.WARN) + end +end + +return M + diff --git a/config/nvim/lua/fschauen/filetype.lua b/config/nvim/lua/fschauen/filetype.lua new file mode 100644 index 0000000..0dda927 --- /dev/null +++ b/config/nvim/lua/fschauen/filetype.lua @@ -0,0 +1,15 @@ +local M = {} + +M.setup = function() + vim.filetype.add { + pattern = { + ['${HOME}/.ssh/config.d/.*'] = 'sshconfig', + ['.*/ssh/config'] = 'sshconfig', + ['.*/git/config'] = 'gitconfig', + ['.*config/zsh/.*'] = 'zsh', + } + } +end + +return M + diff --git a/config/nvim/lua/fschauen/init.lua b/config/nvim/lua/fschauen/init.lua index 1901e42..cf6db25 100644 --- a/config/nvim/lua/fschauen/init.lua +++ b/config/nvim/lua/fschauen/init.lua @@ -10,81 +10,14 @@ R = function(module) return require(module) end - -local bootstrap_lazy = function(path) - if not vim.loop.fs_stat(path) then - vim.fn.system { - 'git', - 'clone', - '--filter=blob:none', - '--branch=stable', - 'https://github.com/folke/lazy.nvim.git', - path, - } - end - vim.opt.rtp:prepend(path) - return vim.F.npcall(require, 'lazy') -end - -local setup_plugins = function() - local lazy = bootstrap_lazy(vim.fn.stdpath('data') .. '/lazy/lazy.nvim') - if not lazy then - vim.notify('Lazy not installed and failed to bootstrap!', vim.log.levels.WARN) - return - end - - lazy.setup { - spec = 'fschauen.plugins', - -- defaults = { - -- lazy = true, - -- }, - dev = { - path = '~/Projects/nvim-plugins', - fallback = true, - }, - ui = { - border = 'rounded', - title = ' Lazy ', - }, - performance = { - rtp = { - disabled_plugins = { - 'gzip', - 'matchit', - 'matchparen', - 'netrwPlugin', - 'tarPlugin', - 'tohtml', - 'tutor', - 'zipPlugin', - }, - }, - }, - } -end - M.setup = function() require('fschauen.options').setup() require('fschauen.keymap').setup() require('fschauen.diagnostic').setup() require('fschauen.autocmd').setup() - - vim.filetype.add { - pattern = { - ['${HOME}/.ssh/config.d/.*'] = 'sshconfig', - ['.*/ssh/config'] = 'sshconfig', - ['.*/git/config'] = 'gitconfig', - ['.*config/zsh/.*'] = 'zsh', - } - } - - setup_plugins() - - local colorscheme = 'gruvbox' - vim.cmd('silent! colorscheme ' .. colorscheme) - if vim.v.errmsg ~= '' then - vim.notify(('Colorscheme %s not found!'):format(colorscheme), vim.log.levels.WARN) - end + require('fschauen.filetype').setup() + require('fschauen.lazy').setup() + require('fschauen.colorscheme').setup() end return M diff --git a/config/nvim/lua/fschauen/lazy.lua b/config/nvim/lua/fschauen/lazy.lua new file mode 100644 index 0000000..e071a43 --- /dev/null +++ b/config/nvim/lua/fschauen/lazy.lua @@ -0,0 +1,53 @@ +local M = {} + +local bootstrap_lazy = function(path) + if not vim.loop.fs_stat(path) then + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + '--branch=stable', + 'https://github.com/folke/lazy.nvim.git', + path, + } + end + vim.opt.rtp:prepend(path) + return vim.F.npcall(require, 'lazy') +end + +M.setup = function() + local lazy = bootstrap_lazy(vim.fn.stdpath('data') .. '/lazy/lazy.nvim') + if not lazy then + vim.notify('Lazy not installed and failed to bootstrap!', vim.log.levels.WARN) + return + end + + lazy.setup { + spec = 'fschauen.plugins', + dev = { + path = '~/Projects/nvim-plugins', + fallback = true, + }, + ui = { + border = 'rounded', + title = ' Lazy ', + }, + performance = { + rtp = { + disabled_plugins = { + 'gzip', + 'matchit', + 'matchparen', + 'netrwPlugin', + 'tarPlugin', + 'tohtml', + 'tutor', + 'zipPlugin', + }, + }, + }, + } +end + +return M +