Skip to content

Instantly share code, notes, and snippets.

@shadmansaleh
Created February 4, 2021 16:54
Show Gist options
  • Save shadmansaleh/4431b59f4b694acf5df2c1c4cf2f94cb to your computer and use it in GitHub Desktop.
Save shadmansaleh/4431b59f4b694acf5df2c1c4cf2f94cb to your computer and use it in GitHub Desktop.
lua << LUA_END
my_namespace78 = {}
function my_namespace78.setup_path()
local split_paths = vim.split(package.path, ";")
local paths = {}
for _, v in ipairs(split_paths) do
table.insert(paths, vim.fn.fnamemodify(v, ":p:h"))
end
local concat_paths = table.concat(paths, ",")
-- TODO: Make sure we don't put this in over and over and over...
vim.bo.path = concat_paths .. "," .. vim.o.path
end
function my_namespace78.get_lua_runtime()
my_namespace78.setup_path()
local result = {};
for _, path in pairs(vim.api.nvim_list_runtime_paths()) do
local lua_path = path .. "/lua/";
if vim.fn.isdirectory(lua_path) then
result[lua_path] = true
end
end
-- This loads the `lua` files from nvim into the runtime.
result[vim.fn.expand("$VIMRUNTIME/lua")] = true
-- TODO: Figure out how to get these to work...
-- Maybe we need to ship these instead of putting them in `src`?...
result[vim.fn.expand("~/build/neovim/src/nvim/lua")] = true
return result;
end
LUA_END
let lua_lsp = glob('~/.cache/nvim/nvim_lsp/sumneko_lua*', 0, 1)
if len(lua_lsp)
let lua_lsp = lua_lsp[-1] . '/lua-language-server'
call coc#config('languageserver', {
\ 'lua-language-server': {
\ 'cwd': lua_lsp,
\ 'command': lua_lsp . '/bin/Linux/lua-language-server',
\ 'args': ['-E', '-e', 'LANG="zh-cn"', lua_lsp . '/main.lua'],
\ 'filetypes': ['lua'],
\ 'settings' : {
\ "Lua" : {
\ "workspace": {
\ "library": v:lua.my_namespace78.get_lua_runtime(),
\ "maxPreload": 1000,
\ "preloadFileSize": 1000
\ },
\ "runtime": {
\ "version": "Lua 5.1"
\ },
\ "diagnostics": {
\ "enable": v:true,
\ "globals": ["hs", "vim", "it", "describe", "before_each", "after_each"],
\ "disable": ["lowercase-global"]
\ },
\ "completion": {
\ "keywordSnippet": "Disable"
\ }
\ }
\ }
\ }
\})
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment