@@ -6,6 +6,8 @@ if not has_lsp then
66 return
77end
88
9+ local is_mac = vim .fn .has " macunix" == 1
10+
911local lspconfig_util = require " lspconfig.util"
1012
1113local ok , nvim_status = pcall (require , " lsp-status" )
@@ -281,33 +283,83 @@ for server, config in pairs(servers) do
281283 setup_server (server , config )
282284end
283285
284- -- Load lua configuration from nlua.
285- _ = require (" nlua.lsp.nvim" ).setup (lspconfig , {
286- on_init = custom_init ,
287- on_attach = custom_attach ,
288- capabilities = updated_capabilities ,
286+ if is_mac then
287+ local sumneko_cmd , sumneko_env = nil , nil
288+ require (" nvim-lsp-installer" ).setup {
289+ automatic_installation = false ,
290+ ensure_installed = { " sumneko_lua" },
291+ }
289292
290- root_dir = function (fname )
291- if string.find (vim .fn .fnamemodify (fname , " :p" ), " xdg_config/nvim/" ) then
292- return vim .fn .expand " ~/git/config_manager/xdg_config/nvim/"
293- end
293+ sumneko_cmd = {
294+ vim .fn .stdpath " data" .. " /lsp_servers/sumneko_lua/extension/server/bin/lua-language-server" ,
295+ }
294296
295- -- ~/git/config_manager/xdg_config/nvim/...
296- return lspconfig_util .find_git_ancestor (fname ) or lspconfig_util .path .dirname (fname )
297- end ,
297+ local process = require " nvim-lsp-installer.core.process"
298+ local path = require " nvim-lsp-installer.core.path"
298299
299- globals = {
300- -- Colorbuddy
301- " Color " ,
302- " c " ,
303- " Group " ,
304- " g " ,
305- " s " ,
300+ sumneko_env = {
301+ cmd_env = {
302+ PATH = process . extend_path {
303+ path . concat { vim . fn . stdpath " data " , " lsp_servers " , " sumneko_lua " , " extension " , " server " , " bin " } ,
304+ } ,
305+ } ,
306+ }
306307
307- -- Custom
308- " RELOAD" ,
309- },
310- })
308+ setup_server (" sumneko_lua" , {
309+ settings = {
310+ Lua = {
311+ diagnostics = {
312+ globals = {
313+ -- Colorbuddy
314+ " Color" ,
315+ " c" ,
316+ " Group" ,
317+ " g" ,
318+ " s" ,
319+
320+ -- Custom
321+ " RELOAD" ,
322+ },
323+ },
324+
325+ workspace = {
326+ -- Make the server aware of Neovim runtime files
327+ library = vim .api .nvim_get_runtime_file (" " , true ),
328+ },
329+ },
330+ },
331+ })
332+ else
333+ -- Load lua configuration from nlua.
334+ _ = require (" nlua.lsp.nvim" ).setup (lspconfig , {
335+ cmd = sumneko_cmd ,
336+ cmd_env = sumneko_env ,
337+ on_init = custom_init ,
338+ on_attach = custom_attach ,
339+ capabilities = updated_capabilities ,
340+
341+ root_dir = function (fname )
342+ if string.find (vim .fn .fnamemodify (fname , " :p" ), " xdg_config/nvim/" ) then
343+ return vim .fn .expand " ~/git/config_manager/xdg_config/nvim/"
344+ end
345+
346+ -- ~/git/config_manager/xdg_config/nvim/...
347+ return lspconfig_util .find_git_ancestor (fname ) or lspconfig_util .path .dirname (fname )
348+ end ,
349+
350+ globals = {
351+ -- Colorbuddy
352+ " Color" ,
353+ " c" ,
354+ " Group" ,
355+ " g" ,
356+ " s" ,
357+
358+ -- Custom
359+ " RELOAD" ,
360+ },
361+ })
362+ end
311363
312364if pcall (require , " sg.lsp" ) then
313365 require (" sg.lsp" ).setup {
0 commit comments