lunarvim - javascript LS Inactive. How do I activate the language server for javascript? - lunarvim

Just installed lunarvim and testing the LSP feature. if I create a python file, looks like "pyright" is used as the language server. If I create a test javascript file like "test1.js", I see at the bottom right hand corner "LS Inactive". Is there a way to activate the language server for javascript?

Answering my own question.
Looks like LunarVim (and/or LSP) is looking for package.json. Just created an empty package.json on the same directory and now LunarVim is using "tsserver".

Related

VSCode: how to structure a simple python package with few modules and tests, debugging and linting?

I'm having more trouble than I'd like to admit to structure a simple project in Python to develop using Visual Studio Code.
How should I structure in my file system a project that is a simple Python package with a few modules? Just a bunch of *.py files together. My requisites are:
I must be able to step debug it in vscode.
It has a bunch of unit tests using pytest.
I can select to debug a specific test from vscode tab and it must stop in breakpoints.
pylint must not show any false positives.
The test files must be in a different directory of the main module files.
I must be able to run all the tests from the console.
The module is executed inside a virtual environment using python standard lib module venv
The code will use type hints
I may use another linter, even another test framework.
Nothing fancy, but I'm really having trouble to get it right. I want to know:
How should I organize my subdirectory: a folder with the main files and a sibling folder with the tests? Or a subfolder with the code and a subsubfolder with the tests?
Which dirs must have a init.py file?
How the tests should import the files from the module? Should I use relative imports?
Should I create a pytest.ini file?
Should I create a .env file?
What's the content of my launch.json the debugger file config in vscode?
Common dir structure:
app
__init__.py
yourappcode.py
tests (pytest looks for this)
__init__.py
test_yourunittests.py
server.py if you have one
.env
.coveragerc
README.md
Pipfile
.gitignore
pyproject.toml if you want
.vscode (helpful)
launch.json
settings.json
Or you could do one better. Ignore my structure and look at the some of famous python projects github page. Like fastAPI, Flask, asgi, aiohttp are some that I can think of right now
Also:
I think absolute imports are easier to work with compared to relative imports, I could be wrong though
vscode is able to use pytest. Make sure you have a testing extension. Vscode has a built in one im pretty sure. You can configure it to pytest and specify your test dir. You can also run your test from command line. If youre at the root, just running ‘pytest’ will recognise your tests dir if it’s named that by default. Also your actual test files need to start with prefix test_ i think.
The launch.json doesn’t need to be anything special. When you click on the settings button next to play button in the debug panel. Vscode will ask what kind of app is it. I.e If its a flask app, select python then select flask and it will auto generate a settings file which you can tweak however you want in order to get your app to run. I.e maybe you want to expose a different port or the commands to run your app are different
It sounds to me like you just need to spend a bit of time configuring vscode to your specific python needs. For example, you can use a virtualenv and linting in whichever way you want. You just need to have a settings.json file in the .vscode folder in your repo where you specify your settings. Configurations to specify python virtualenv and linting methods can be found online

How to open a file in vscode from browser?

I want my webapp to be able to open a given file in VS code. For example, when I click a button on my webapp, a file say, C:\Users\...\myProject\index.html is opened, if myProject is already opened it should navigate to index.html
I know its a peculiar use case but I want to know if its possible in vscode.
Its also completely fine if it requires using browser or vscode extension.
vscode://file/{full path to project}/
Thanks to fbg13 for providing this link
It is possible if you are using Firefox:
Open the about:config page.
Set the view_source.editor.external to true.
Set the view_source.editor.path to the VSCode's executable absolute path.
It is possible if you add this link:
vscode://file/{fullpath}:{numrow}
Example for Symfony 5.3 and higher
For example in Symfony to use the link that appears in the debug bar of the controller used you can do it as described in the examples. You have to edit your project config.
Only for VS Code:
config\packages\framework.yaml
framework:
ide: 'vscode://file/%%f:%%l'
For any editor through env:
config\packages\framework.yaml
framework:
ide: '%env(resolve:CODE_EDITOR)%'
And don't forget to add value for CODE_EDITOR into .env or .env.local.
Local
This is an example for local projects.
.env or .env.local:
CODE_EDITOR=vscode
# or
CODE_EDITOR=vscode://file/%%f:%%l
Docker
If you use Docker or trying to open a file from remote server, you may use this example.
.env or .env.local:
# Template
CODE_EDITOR=vscode://file/%%f:%%l&/PATH/TO/YOUR/SERVER/APP>/PATH/TO/YOUR/LOCAL/APP
# Real paths
CODE_EDITOR=vscode://file/%%f:%%l&/app/>/home/user/projects/symfony_project/
For more details see these pages:
Symfony Framework Configuration Reference - ide
Opening VS Code with URLs
You can install vscode-handler to open files like this
vscode://open?url=file://%file&line=%line

is there a coffeescript auto compile / file watcher for windows?

I'd like to play around with integrating coffeescript into my dev process. But as I see it, I'll have to make a bat file that iterates a set of coffee files and spits out js files. Every time I write a bat file, useful as they may be, I ask myself: is there a better way?
Which makes me wonder: is there an app of some sort for Windows that will watch a directory or a file and spit out one/many js files when a coffee file is saved? I'm thinking of building one but don't want to reinvent the wheel. I looked around and found things that were similar but nothing that elevated it beyond "run this command line" on Windows.
Edit: already marked an answer, but looking at this 10 months later the answer is: grunt. Because it'll do a lot more than just auto-compile your coffeescript and you'll probably need to do more than just that to get your app going.
coffee --watch -o lib -c src
where src is a directory containing your coffee files, and lib is your JavaScript output directory.
See update at bottom of post.
I was hunting for the same thing the other day and came across this: https://github.com/danenania/CoffeePy
It's a simple python script that uses PyV8 to run coffee-script.js.
It doesn't do anything fancy, just watches a folder recursively, and compiles any .coffee files whenever they're changed. It doesn't even have a bare option. These things could be very easily added though!
Edit:
I forked the script and added --bare and --output options.
You can get it here: https://github.com/johtso/CoffeePy
Personally, I prefer using build tools like grunt.js / yeoman or brunch for that purpose.
grunt.js
&
grunt coffee
Mindscape Workbench has a built in compiler/editor for VS 2010. Haven't tried it yet, but it looks like it'd be even better than a watcher/compiler. Scott Hanselman has a post about it here:
http://www.hanselman.com/blog/CoffeeScriptSassAndLESSSupportForVisualStudioAndASPNETWithTheMindscapeWebWorkbench.aspx
I think there is a simplier way just using -w option of coffeescript compiler
coffee -c -w *.coffee
This will compile all coffee files under the folder you are (put more file pathes if needed) each time you change one.
Another possibility: WebStorm 6. They've added a built in file-watcher for a variety of next-gen languages like SASS and Coffescript.
If you want a different way of doing it, this might help:
http://jashkenas.github.com/coffee-script/#scripts
If you include the coffeescript compiler on your page, you can include files with a "text/coffeescript" type and they will get compiled client-side.
Word of warning: Obviously, client-side compilation is not for something serious, but its completely fine for a small project/quick development. It would then be trivial to compile them on the server and change the MIME-type and filename when something a bit quicker is necessary.
CoffeeScript-dotnet does what you want, but it is a command line tool.
Command line tool for compiling CoffeeScript. Includes a file system watcher to automatically recompile CoffeeScripts when they change. Roughly equivalent to the coffee-script node package for linux / mac.
Here is the best way to do it:
Say your work is in "my-project-path" folder.
Go to the parent folder of "my-project-path"
Start a terminal and type coffee -o my-project-path -cw my-project-path
This line will watch and compile anything name as "*.coffee" in "my-project-path" folder, even if it is in "my-project-path/scripts/core" or "my-project-path/test/core".The js file will locate in the save folder as the .coffee file.

How to generate phpDoc documentation for a specific folder in Netbeans IDE?

Due to the fact that we need to integrate the Zend Framework on our project root, and that generating that documentation will be useless and take long time, I would like to generate documentation for all files inside application folder only.
Does anyone know how I can generate documentation for a specific project folder, trough Netbeans 7.0 interface?
Update:
The best I've found so far was to:
Open the terminal window from netbeans, and type:
sudo phpdoc -d public_html/yoursite.dev/application/ -t public_html/yoursite.dev/docs/
Update 2
Let's suppose our Zend library is inside projectrootname/library/Zend we also can try, by going to: Tools > Options > Php > PhpDoc and place the following:
/usr/bin/phpdoc -i library/Zend/ -o HTML:frames:earthli
At least for me, that doesn't seem to work, because, when I try to generate the documentation, I get permission error issues displayed on the output window.
Thanks
The -d/--directory option [1] should be used to highlight the most high-level code directory that you want phpDocumentor to start reading from. If your Zend folder is at or above the level of your application directory, then just using --directory /path/to/application should help you document only your application code.
If your Zend folder is somewhere inside your application (e.g. in your app's ./lib folder), then you can use the -i/--ignore option [2] to tell phpDocumentor about any directories that it will see but should ignore, --ignore *zend*. Just be aware that formatting your ignore value can be tricky, so see the examples in the manual. Also, be aware that as phpDocumentor runs, you will see these ignored folders and files being listed in the output... phpDocumentor "ignores" them by not generating docs for those files. It does, however, still need to parse them, in case those objects are referenced in files that do get documented.
[1] -- http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#using.command-line.directory
[2] -- http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#using.command-line.ignore

run compass watch terminal command upon opening the folder with textmate

I use textmate for website development and compass to compile css stylesheets. Right now everytime I open up the folder with textmate I have to additionally run a compass watch /path/to/folder command. I know textmate is pretty powerfull, but not sure how to make it work so the compass watch command is automatically applied to projects you open with textmate (I usually drag the projectfolder on the dock-icon). Is this possible?
Sure thing. You will need to make a small function in your .bashrc file.
I based the function below off an alias I create for SublimeText2 to make it work like "mate dir/" (a feature I missed greatly):
#Sublime Text Alias
alias slime='open -a "/Applications/Sublime Text 2.app"'
So, you don't really want an alias to run two commands, since an alias is...an "alias" for a specific command. However, a function is well suited:
#for Textmate
function matew() {
open -a "/Applications/TextMate.app" $1
compass watch $1
}
I picked "matew" - cause it was like mate+watch, but you can call your function whatever you will remember. (e.g epicPwn(), etc) Thus, your new function is run as:
matew dirName/
Note: Just be sure to put the correct path to TextMate. Also, the compass watch command will fowl up if you aren't passing a directory, obviously. Similarly if the directory doesn't have a compass project -> compass watch will spit back a standard "no project" error (but TM will still open the dir/). e.g.:
matew src/
Nothing to compile. If you're trying to start a new project, you have left off the directory argument.
Run "compass -h" to get help.