neovim configuration using rocks.nvim plugin manager
at main 2.4 kB view raw
1---@class bt.util 2---@field notify bt.util.notify 3---@field highlights bt.util.highlights 4---@field format bt.util.format 5local M = {} 6setmetatable(M, { 7 __index = function(t, k) 8 t[k] = require("utils." .. k) 9 return t[k] 10 end, 11}) 12 13---@param ms number 14---@param fn function 15---@return function 16function M.debounce(ms, fn) 17 local timer = vim.uv.new_timer() 18 return function(...) 19 local argv = {...} 20 timer:start(ms, 0, function() 21 timer:stop() 22 vim.schedule_wrap(fn)(unpack(argv)) 23 end) 24 end 25end 26 27---@param client vim.lsp.Client 28function M.lazydev_is_not_working(client) 29 local path = vim.tbl_get(client,"workspace_folders", 1, "name") 30 if not path then 31 vim.print("no workspace") 32 return 33 end 34 client.settings = vim.tbl_deep_extend('force', client.settings, { 35 Lua = { 36 runtime = { 37 version = 'LuaJIT' 38 }, 39 -- Make the server aware of Neovim runtime files 40 workspace = { 41 checkThirdParty = false, 42 library = { 43 vim.env.VIMRUNTIME 44 -- Depending on the usage, you might want to add additional paths here. 45 -- "${3rd}/luv/library" 46 -- "${3rd}/busted/library", 47 } 48 -- or pull in all of 'runtimepath'. NOTE: this is a lot slower 49 -- library = vim.api.nvim_get_runtime_file("", true) 50 } 51 } 52 }) 53end 54 55---@param lang string 56---@param filetype string? 57function M.load_local_parser(lang, filetype) 58 filetype = filetype or lang 59 local parser = string.format("$HOME/.cache/tree-sitter/lib/%s.so", lang) 60 if vim.fn.has("macunix") == 1 then 61 parser = string.format("$HOME/.cache/tree-sitter/lib/%s.dylib", lang) 62 end 63 local path = vim.fs.normalize(parser) 64 if not vim.uv.fs_stat(path) then 65 return 66 end 67 vim.treesitter.language.add(lang, { 68 path = path, 69 filetype = filetype, 70 }) 71 if not vim.treesitter.language.get_lang(filetype) then 72 vim.treesitter.language.register(lang, filetype) 73 end 74 vim.api.nvim_create_autocmd("FileType", { 75 pattern = filetype, 76 callback = function (ev) 77 vim.treesitter.start(ev.buf, lang) 78 end 79 }) 80end 81 82return M