[mirror] Make your go dev experience better
github.com/olexsmir/gopher.nvim
neovim
golang
1local function root(p)
2 local f = debug.getinfo(1, "S").source:sub(2)
3 return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (p or "")
4end
5
6local function install_plug(plugin)
7 local name = plugin:match ".*/(.*)"
8 local package_root = root ".tests/site/pack/deps/start/"
9 if not vim.uv.fs_stat(package_root .. name) then
10 print("Installing " .. plugin)
11 vim
12 .system({
13 "git",
14 "clone",
15 "--depth=1",
16 "https://github.com/" .. plugin .. ".git",
17 package_root .. "/" .. name,
18 })
19 :wait()
20 end
21end
22
23install_plug "nvim-lua/plenary.nvim"
24install_plug "nvim-treesitter/nvim-treesitter"
25install_plug "echasnovski/mini.doc" -- used for docs generation
26install_plug "echasnovski/mini.test"
27
28vim.env.XDG_CONFIG_HOME = root ".tests/config"
29vim.env.XDG_DATA_HOME = root ".tests/data"
30vim.env.XDG_STATE_HOME = root ".tests/state"
31vim.env.XDG_CACHE_HOME = root ".tests/cache"
32
33vim.cmd [[set runtimepath=$VIMRUNTIME]]
34vim.opt.runtimepath:append(root())
35vim.opt.packpath = { root ".tests/site" }
36vim.notify = vim.print
37
38-- install go treesitter parse
39require("nvim-treesitter.install").ensure_installed_sync "go"
40
41require("gopher").setup {
42 log_level = vim.log.levels.OFF,
43 timeout = 4000,
44}
45
46-- setup mini.test only when running headless nvim
47if #vim.api.nvim_list_uis() == 0 then
48 require("mini.test").setup {
49 collect = {
50 find_files = function()
51 return vim.fn.globpath("spec", "**/*_test.lua", true, true)
52 end,
53 },
54 }
55end