Skip to content

Commit

Permalink
fix start fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Lycs-D committed Apr 10, 2024
1 parent 9ba1aa8 commit 8702e83
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
42 changes: 29 additions & 13 deletions src/server/general.v
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fn (mut ls LanguageServer) setup() {
ls.client.log_message('No config found', .warning)
loglib.warn('No config found')
ls.setup_toolchain()
ls.setup_vpaths() or { loglib.error(err.msg()) }
ls.setup_vpaths()
return
}

Expand Down Expand Up @@ -233,7 +233,7 @@ fn (mut ls LanguageServer) setup() {
ls.setup_cache_dir()
}

ls.setup_vpaths() or { loglib.error(err.msg()) }
ls.setup_vpaths()
}

fn (mut ls LanguageServer) setup_cache_dir() {
Expand Down Expand Up @@ -301,21 +301,37 @@ Global config path: ${config.analyzer_configs_path}/${config.analyzer_config_nam
}
}

fn (mut ls LanguageServer) setup_vpaths() ! {
fn (mut ls LanguageServer) setup_vpaths() {
vlib_path := os.join_path(ls.paths.vroot, 'vlib')
if !os.is_dir(vlib_path) {
return error('Failed to find standard library path')
if os.is_dir(vlib_path) {
ls.paths.vlib_root = vlib_path
msg := 'Using "${vlib_path}" as vlib root'
ls.client.log_message(msg, .info)
loglib.info(msg)
} else {
msg := 'Failed to find standard library path'
ls.client.log_message(msg, .warning)
loglib.warn(msg)
}
ls.paths.vlib_root = vlib_path
vmodules_root := os.vmodules_dir()
if !os.is_dir(ls.paths.vmodules_root) {
return error('Failed to find vmodules path')
if os.is_dir(vmodules_root) {
ls.paths.vmodules_root = vmodules_root
msg := 'Using "${vmodules_root}" as vmodules root'
ls.client.log_message(msg, .info)
loglib.info(msg)
}
vexe := os.join_path(ls.paths.vroot, $if windows { 'v.exe' } $else { 'v' })
if os.is_file(vexe) {
ls.paths.vexe = vexe
ls.reporter.compiler_path = vexe
msg := 'Using "${vexe}" as vexe root'
ls.client.log_message(msg, .info)
loglib.info(msg)
} else {
msg := 'Failed to find v executable path'
ls.client.log_message(msg, .warning)
loglib.warn(msg)
}
ls.paths.vmodules_root = vmodules_root
ls.client.log_message('Using "${ls.paths.vmodules_root}" as vmodules root', .info)
loglib.info('Using "${ls.paths.vmodules_root}" as vmodules root')
ls.paths.vexe = os.join_path(ls.paths.vroot, $if windows { 'v.exe' } $else { 'v' })
ls.reporter.compiler_path = ls.paths.vexe
}

fn (mut ls LanguageServer) setup_config_dir() {
Expand Down
12 changes: 8 additions & 4 deletions src/server/language_server.v
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,12 @@ pub fn (mut ls LanguageServer) register_compiler_quick_fix(quickfix intentions.C
// p.wait()
// ```
pub fn (mut ls LanguageServer) launch_tool(args ...string) !&os.Process {
mut p := os.new_process(ls.paths.vexe)
p.set_args(args)
p.set_redirect_stdio()
return p
if os.is_file(ls.paths.vexe) {
mut p := os.new_process(ls.paths.vexe)
p.set_args(args)
p.set_redirect_stdio()
return p
} else {
return error('No toolchain')
}
}

0 comments on commit 8702e83

Please sign in to comment.