|
1 | | -vim.cmd([[set runtimepath=$VIMRUNTIME]]) |
2 | | -vim.cmd([[set packpath=/tmp/nvim/site]]) |
3 | | - |
4 | | -local package_root = '/tmp/nvim/site/pack' |
5 | | -local install_path = package_root .. '/packer/start/packer.nvim' |
6 | | - |
7 | | -local function load_plugins() |
8 | | - require('packer').startup({ |
9 | | - { |
10 | | - 'wbthomason/packer.nvim', |
11 | | - { 'nvim-treesitter/nvim-treesitter' }, |
12 | | - { 'kristijanhusak/orgmode.nvim', branch = 'master' }, |
13 | | - }, |
14 | | - config = { |
15 | | - package_root = package_root, |
16 | | - compile_path = install_path .. '/plugin/packer_compiled.lua', |
17 | | - }, |
| 1 | +local nvim_root = '/tmp/nvim_orgmode' |
| 2 | +local lazy_root = nvim_root .. '/lazy' |
| 3 | +local lazypath = lazy_root .. '/lazy.nvim' |
| 4 | + |
| 5 | +-- Install lazy.nvim if not already installed |
| 6 | +if not vim.loop.fs_stat(lazypath) then |
| 7 | + vim.fn.system({ |
| 8 | + 'git', |
| 9 | + 'clone', |
| 10 | + '--filter=blob:none', |
| 11 | + 'https://github.com/folke/lazy.nvim.git', |
| 12 | + '--branch=stable', -- latest stable release |
| 13 | + lazypath, |
18 | 14 | }) |
19 | 15 | end |
| 16 | +vim.opt.rtp:prepend(lazypath) |
20 | 17 |
|
21 | | -_G.load_config = function() |
22 | | - require('orgmode').setup_ts_grammar() |
23 | | - require('nvim-treesitter.configs').setup({ |
24 | | - highlight = { |
25 | | - enable = true, |
26 | | - additional_vim_regex_highlighting = { 'org' }, |
| 18 | +require('lazy').setup({ |
| 19 | + { |
| 20 | + 'nvim-orgmode/orgmode', |
| 21 | + dependencies = { |
| 22 | + { 'nvim-treesitter/nvim-treesitter', lazy = true }, |
27 | 23 | }, |
28 | | - }) |
29 | | - |
30 | | - vim.cmd([[packadd nvim-treesitter]]) |
31 | | - vim.cmd([[runtime plugin/nvim-treesitter.lua]]) |
32 | | - vim.cmd([[TSUpdateSync org]]) |
33 | | - |
34 | | - -- Close packer after install |
35 | | - if vim.bo.filetype == 'packer' then |
36 | | - vim.api.nvim_win_close(0, true) |
37 | | - end |
38 | | - |
39 | | - require('orgmode').setup() |
40 | | - |
41 | | - -- Reload current file if it's org file to reload tree-sitter |
42 | | - if vim.bo.filetype == 'org' then |
43 | | - vim.cmd([[edit!]]) |
44 | | - end |
45 | | -end |
46 | | - |
47 | | -if vim.fn.isdirectory(install_path) == 0 then |
48 | | - vim.fn.system({ 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }) |
49 | | - load_plugins() |
50 | | - require('packer').sync() |
51 | | - vim.cmd([[autocmd User PackerCompileDone ++once lua load_config()]]) |
52 | | -else |
53 | | - load_plugins() |
54 | | - load_config() |
55 | | -end |
| 24 | + event = 'VeryLazy', |
| 25 | + config = function() |
| 26 | + -- Load treesitter grammar for org |
| 27 | + require('orgmode').setup_ts_grammar() |
| 28 | + |
| 29 | + -- Setup treesitter |
| 30 | + require('nvim-treesitter.configs').setup({ |
| 31 | + highlight = { |
| 32 | + enable = true, |
| 33 | + additional_vim_regex_highlighting = { 'org' }, |
| 34 | + }, |
| 35 | + ensure_installed = { 'org' }, |
| 36 | + }) |
| 37 | + |
| 38 | + -- Setup orgmode |
| 39 | + require('orgmode').setup() |
| 40 | + end, |
| 41 | + }, |
| 42 | +}, { |
| 43 | + root = lazy_root, |
| 44 | + lockfile = nvim_root .. '/lazy.json', |
| 45 | + install = { |
| 46 | + missing = false, |
| 47 | + }, |
| 48 | +}) |
| 49 | + |
| 50 | +require('lazy').sync({ |
| 51 | + wait = true, |
| 52 | + show = false, |
| 53 | +}) |
0 commit comments