tamago324 / nlsp-settings.nvim

A plugin for setting Neovim LSP with JSON or YAML files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Script jsonls.lua is broken on OS:Windows

DrKGD opened this issue · comments

Following the configuration found in the README "usage" section, neovim on OS:Windows doesn't seem to be too happy about it.

E5108: Error executing lua ...ker\start\nlsp-settings.nvim\lua\nlspsettings\jsonls.lua:7: attempt to concatenate a nil value
"~\.config\nvim/nlsp-settings/jsonls.json" 4 righe,10 caratteri
"~\.local\share\nvim-data\site\pack\packer\start\nlsp-settings.nvim\lua\nlspsettings\jsonls.lua" 69 righe,1570 caratteri
"~\.local\share\nvim-data\site\pack\packer\start\nlsp-settings.nvim\scripts\gen_schemas_readme.lua" 72 righe,1704 caratteri
"~\.local\share\nvim-data\site\pack\packer\start\nlsp-settings.nvim\schemas\_generated\jsonls.json" 78 righe,2145 caratteri

The error is thrown upon calling this very line in the jsonls configuration:

schemas = require('nlspsettings.jsonls').get_default_schemas()

Seems like _schemas_dir is empty reason being the string.match function is returning nil due to Windows-Unix different slash notation.

local _schemas_dir = script_abspath():match('(.*)/lua/nlspsettings/jsonls.lua$') .. '/schemas'

The following seems to work as a temporary solution (I can't really think of another way using regex as I am really bad with it :/)

local _schemas_dir
if vim.fn.has('win32')	== 1 then
	_schemas_dir = script_abspath():match('(.*)\\lua\\nlspsettings\\jsonls.lua$') .. '\\schemas'
else 
	_schemas_dir = script_abspath():match('(.*)/lua/nlspsettings/jsonls.lua$') .. '/schemas'
end

Other than that, thanks for the plugin!
I really hope at some point this will be able to support C-family languages (C, Cpp with clang)!