-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathminimal_init.lua
More file actions
67 lines (62 loc) · 1.66 KB
/
minimal_init.lua
File metadata and controls
67 lines (62 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
-- Add current directory to 'runtimepath' to be able to use 'lua' files
vim.cmd([[let &rtp.=','.getcwd()]])
local runtime_dependencies = {
"deps/mini.nvim",
"deps/nvim-treesitter",
"deps/neotest",
"deps/neotest-python",
"deps/nvim-dap",
"deps/nvim-dap-python",
"deps/nvim-lspconfig",
"deps/LuaSnip",
}
local runtime_path = vim.fn.join(runtime_dependencies, ",")
vim.cmd("set rtp+=" .. runtime_path)
-- Set up 'mini.test'
require("luasnip.extras.fmt")
require("luasnip.nodes.absolute_indexer")
require("nvim-treesitter.locals")
require("nvim-treesitter").setup()
require("mini.test").setup()
require("mini.doc").setup()
require("nvim-treesitter.configs").setup({
modules = {
"highlight",
},
sync_install = false,
auto_install = true,
ignore_install = {},
ensure_installed = {},
highlight = {
enable = true,
},
})
-- Clean path for use in a prefix comparison
---@param input string
---@return string
local function clean_path(input)
local pth = vim.fn.fnamemodify(input, ":p")
if vim.fn.has("win32") == 1 then
pth = pth:gsub("/", "\\")
end
return pth
end
local function ts_is_installed(lang)
local matched_parsers = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true) or {}
local configs = require("nvim-treesitter.configs")
local install_dir = configs.get_parser_install_dir()
if not install_dir then
return false
end
install_dir = clean_path(install_dir)
for _, path in ipairs(matched_parsers) do
local abspath = clean_path(path)
if vim.startswith(abspath, install_dir) then
return true
end
end
return false
end
if not ts_is_installed("python") then
vim.cmd("TSInstallSync python")
end