33 lines
973 B
Lua
33 lines
973 B
Lua
local teaching = {}
|
|
|
|
local function ends_with(path, extension)
|
|
return string.sub(path, -#extension) == extension
|
|
end
|
|
|
|
local function should_load(path)
|
|
if string.find(path, "build") or string.find(path, "sfml") then
|
|
return false
|
|
elseif ends_with(path, ".h") or ends_with(path, ".cpp") or ends_with(path, ".cpp") or ends_with(path, ".cpp") then
|
|
return true
|
|
end
|
|
end
|
|
|
|
function teaching.load()
|
|
require("nvim-tree").open()
|
|
require("trouble").open()
|
|
local scan = require("plenary.scandir").scan_dir('.')
|
|
local cwd = vim.fn.getcwd()
|
|
for _, v in ipairs(scan) do
|
|
local filename = vim.fs.normalize(v)
|
|
if should_load(v) then
|
|
vim.api.nvim_set_current_dir(cwd)
|
|
local buf_id = vim.fn.bufadd(filename)
|
|
vim.api.nvim_set_current_buf(buf_id)
|
|
vim.api.nvim_buf_set_option(buf_id, "buflisted", true)
|
|
end
|
|
end
|
|
vim.api.nvim_set_current_dir(cwd)
|
|
end
|
|
|
|
return teaching
|