This repository has been archived by the owner on Jul 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
131 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"lua-dev": { | ||
"library": { "plugins": ["workspace.nvim"] } | ||
}, | ||
"lspconfig": { | ||
"sumneko_lua": { "settings": {} } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,106 @@ | ||
local Config = require("lua-dev.config") | ||
|
||
local M = {} | ||
local S = {} | ||
|
||
function M.library() | ||
local ret = {} | ||
function S.get(opts) | ||
local M = {} | ||
|
||
if Config.options.library.types then | ||
ret[M.types()] = true | ||
end | ||
function M.library() | ||
local ret = {} | ||
|
||
if opts.library.types then | ||
ret[M.types()] = true | ||
end | ||
|
||
local function add(lib, filter) | ||
for _, p in pairs(vim.fn.expand(lib .. "/lua", false, true)) do | ||
p = vim.loop.fs_realpath(p) | ||
if p then | ||
-- p = vim.fn.fnamemodify(p, ":h") | ||
local skip = false | ||
if type(filter) == "table" then | ||
local name = vim.fn.fnamemodify(p, ":t") | ||
skip = true | ||
for _, f in pairs(filter) do | ||
if name == f then | ||
skip = false | ||
break | ||
local function add(lib, filter) | ||
for _, p in pairs(vim.fn.expand(lib .. "/lua", false, true)) do | ||
p = vim.loop.fs_realpath(p) | ||
if p then | ||
-- p = vim.fn.fnamemodify(p, ":h") | ||
local skip = false | ||
if type(filter) == "table" then | ||
local name = vim.fn.fnamemodify(p, ":h:t") | ||
skip = true | ||
for _, f in pairs(filter) do | ||
if name == f then | ||
skip = false | ||
break | ||
end | ||
end | ||
end | ||
end | ||
if not skip then | ||
ret[p] = true | ||
if not skip then | ||
ret[p] = true | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
if Config.options.library.vimruntime then | ||
add("$VIMRUNTIME") | ||
end | ||
if opts.library.vimruntime then | ||
add("$VIMRUNTIME") | ||
end | ||
|
||
if Config.options.library.plugins then | ||
for _, site in pairs(vim.split(vim.o.packpath, ",")) do | ||
add(site .. "/pack/*/opt/*", Config.options.library.plugins) | ||
add(site .. "/pack/*/start/*", Config.options.library.plugins) | ||
if opts.library.plugins then | ||
for _, site in pairs(vim.split(vim.o.packpath, ",")) do | ||
add(site .. "/pack/*/opt/*", opts.library.plugins) | ||
add(site .. "/pack/*/start/*", opts.library.plugins) | ||
end | ||
end | ||
end | ||
|
||
return ret | ||
end | ||
return ret | ||
end | ||
|
||
function M.path() | ||
local path = {} --vim.split(package.path, ";") | ||
table.insert(path, "lua/?.lua") | ||
table.insert(path, "lua/?/init.lua") | ||
for lib, _ in pairs(M.library()) do | ||
function M.path() | ||
local path = {} --vim.split(package.path, ";") | ||
table.insert(path, "lua/?.lua") | ||
table.insert(path, "lua/?/init.lua") | ||
-- for lib, _ in pairs(M.library()) do | ||
-- table.insert(path, lib .. "/?.lua") | ||
-- table.insert(path, lib .. "/?/init.lua") | ||
-- end | ||
return path | ||
end | ||
return path | ||
end | ||
|
||
function M.config_path() | ||
return vim.loop.fs_realpath(vim.fn.stdpath("config")) | ||
end | ||
function M.config_path() | ||
return vim.loop.fs_realpath(vim.fn.stdpath("config")) | ||
end | ||
|
||
function M.types() | ||
local f = debug.getinfo(1, "S").source:sub(2) | ||
return vim.loop.fs_realpath(vim.fn.fnamemodify(f, ":h:h:h") .. "/types") | ||
end | ||
function M.types() | ||
local f = debug.getinfo(1, "S").source:sub(2) | ||
return vim.loop.fs_realpath(vim.fn.fnamemodify(f, ":h:h:h") .. "/types") | ||
end | ||
|
||
function M.setup() | ||
local path = M.path() | ||
return { | ||
on_new_config = function(config, root_dir) | ||
local lib = vim.tbl_deep_extend("force", {}, config.settings.Lua.workspace.library) | ||
lib[vim.loop.fs_realpath(root_dir) .. "/lua"] = nil | ||
lib[vim.loop.fs_realpath(root_dir)] = nil | ||
config.settings.Lua.workspace.library = lib | ||
return config | ||
end, | ||
settings = { | ||
Lua = { | ||
runtime = { | ||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) | ||
version = "LuaJIT", | ||
-- Setup your lua path | ||
path = path, | ||
}, | ||
completion = { callSnippet = "Replace" }, | ||
diagnostics = { | ||
-- Get the language server to recognize the `vim` global | ||
globals = { "vim" }, | ||
}, | ||
-- hint = { enable = true }, | ||
workspace = { | ||
-- Make the server aware of Neovim runtime files | ||
library = M.library(), | ||
maxPreload = 1000, | ||
preloadFileSize = 150, | ||
function M.setup() | ||
local path = M.path() | ||
return { | ||
settings = { | ||
Lua = { | ||
runtime = { | ||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) | ||
version = "LuaJIT", | ||
-- Setup your lua path | ||
path = path, | ||
}, | ||
completion = { callSnippet = "Replace" }, | ||
-- diagnostics = { | ||
-- -- Get the language server to recognize the `vim` global | ||
-- globals = { "vim" }, | ||
-- }, | ||
-- hint = { enable = true }, | ||
workspace = { | ||
-- Make the server aware of Neovim runtime files | ||
library = M.library(), | ||
maxPreload = 1000, | ||
preloadFileSize = 150, | ||
}, | ||
-- Do not send telemetry data containing a randomized but unique identifier | ||
telemetry = { enable = false }, | ||
}, | ||
-- Do not send telemetry data containing a randomized but unique identifier | ||
telemetry = { enable = false }, | ||
}, | ||
}, | ||
} | ||
} | ||
end | ||
return M | ||
end | ||
|
||
return M | ||
S = vim.tbl_deep_extend("force", S, S.get(Config.options)) | ||
|
||
return S |