|
| 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 | + }, |
| 18 | + }) |
| 19 | +end |
| 20 | + |
| 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' }, |
| 27 | + }, |
| 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 |
0 commit comments