-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configurations and notes for Astro LS (#43)
* Add configurations and notes for Astro LS
- Loading branch information
Showing
4 changed files
with
115 additions
and
0 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
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,53 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import subprocess, os, sys, platform | ||
|
||
def OnWindows(): | ||
return platform.system() == 'Windows' | ||
|
||
|
||
# On Windows, distutils.spawn.find_executable only works for .exe files | ||
# but .bat and .cmd files are also executables, so we use our own | ||
# implementation. | ||
def FindExecutable( executable ): | ||
# Executable extensions used on Windows | ||
WIN_EXECUTABLE_EXTS = [ '.exe', '.bat', '.cmd' ] | ||
|
||
paths = os.environ[ 'PATH' ].split( os.pathsep ) | ||
base, extension = os.path.splitext( executable ) | ||
|
||
if OnWindows() and extension.lower() not in WIN_EXECUTABLE_EXTS: | ||
extensions = WIN_EXECUTABLE_EXTS | ||
else: | ||
extensions = [ '' ] | ||
|
||
for extension in extensions: | ||
executable_name = executable + extension | ||
if not os.path.isfile( executable_name ): | ||
for path in paths: | ||
executable_path = os.path.join( path, executable_name ) | ||
if os.path.isfile( executable_path ): | ||
return executable_path | ||
else: | ||
return executable_name | ||
return None | ||
|
||
|
||
def FindExecutableOrDie( executable, message ): | ||
path = FindExecutable( executable ) | ||
|
||
if not path: | ||
sys.exit( "ERROR: Unable to find executable '{0}'. {1}".format( | ||
executable, | ||
message ) ) | ||
|
||
return path | ||
|
||
|
||
def Main(): | ||
npm = FindExecutableOrDie( 'npm', 'npm is required to set up Astro LS.' ) | ||
subprocess.check_call( [ npm, 'install', '--production' ] ) | ||
|
||
|
||
if __name__ == '__main__': | ||
Main() |
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,6 @@ | ||
{ | ||
"description": "ycmd astro-ls runtime area", | ||
"dependencies": { | ||
"@astrojs/language-server": "*" | ||
} | ||
} |
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 @@ | ||
let g:ycm_language_server += [ | ||
\ { | ||
\ 'name': 'astro', | ||
\ 'filetypes': [ 'astro' ], | ||
\ 'cmdline': [ expand( g:ycm_lsp_dir . '/astro/node_modules/@astrojs/language-server/bin/nodeServer.js' ), '--stdio' ], | ||
\ 'project_root_files': [ 'tsconfig.json', 'astro.config.mjs' ] | ||
\ }, | ||
\ ] |