How to set the default mode of file in Spacemacs? - spacemacs

Every time I open a .js file with Spacemacs, the default mode is web-mode. But what I want is react-mode.
Is there any way to achieve this ? Thanks.

I found some information from #4751.
We can simply add (add-to-list 'auto-mode-alist '("\\.js\\'" . react-mode)) to docspacemacs/user-config in .spacemacs.

Related

is there any way to splitting Variables in VSCode?

I wonder there is any way to splitting some variables in VSCode?
my example will explain my question better:
I have an exe file in such path C:\path\to\workspace\main\project\project.exe
my cpp source path that will create exe file is this C:\path\to\workspace\main\project\test.cpp
I want to create a task in tasks.json but my oder of variables does not give me the right path
as you understand:
${workspaceFolder} is C:\path\to\workspace
${fileDirname} returns C:\path\to\workspace\main\project
and ${relativeFileDirname}.exe returns main\project.exe
and combination of "${fileDirname}\\${relativeFileDirname}.exe" as a command will return C:\path\to\workspace\main\project\main\project.exe that is wrong.
so I wanted to know there is any other variable that just return the parent of current file or not?
if not can we split variables with \ ?
I hope it makes some sense
thanks
Add new fileDirnameBasename variable
see https://github.com/microsoft/vscode/commit/551db7ec94f02a4bdc8999092cf8bef642b3992d
${fileDirnameBasename} is being added to vscode v1.52 which I believe is what you are looking for.
You can use the extension Command Variable
Use the commands:
extension.commandvariable.file.fileDirBasename
extension.commandvariable.file.fileDirBasename1Up
extension.commandvariable.file.fileDirBasename2Up
btw, as an workaround, this worked for me
"${fileDirname}\\*.exe"
but need a variable for getting parent folder of current open file
any idea?

How to set lxcpath in config files?

I have put lxc.lxcpath=/my/path into /etc/lxc/lxc.conf and /usr/local/etc/lxc/default.conf but when I run lxc-config lxc.lxcpath it still shows a different path. How can I set the lxcpath? This is with lxc2.1.1 installed from sources.
If you are running
lxc-config lxc.lxcpath
as non-root, then you need to edit ~/.config/lxc/lxc.conf instead of /etc/lxc/lxc.conf. As in:
serge#sl:~$ echo "lxc.lxcpath = /tmp/xxx" > ~/.config/lxc/lxc.conf
serge#sl:~$ lxc-config lxc.lxcpath
/tmp/xxx
Alternatively, since you said you installed from source, it is possible that you need to edit /usr/local/etc/lxc/lxc.conf instead. You can find the path in config.log, i.e.:
LXC_GLOBAL_CONF='/usr/local/etc/lxc/lxc.conf'

IntelliJ - File watchers: wrong output of macros

I am trying to setup a file watcher for scss files which is working on files with a filename not starting with _.
But if I have a file named _file_name.scss the output of any macros that include the filename will be file.name.scss.
The first _ is removed and following ones are replaced by ..
Even though in the insert macros selection tool I can see that the output when you select a macro is correct.
Like $FilePathRelativeToProjectRoot$ will display mypath/_file_name.scss in the selection tool but then my command from this file watcher will output mypath/file.name.scss.
Am I missing a parameter here ?
Full configuration:
For me, existing file names are not changed when using similar file watcher. But files with names starting the _ are not prettified, the main .scss that includes them is processed instead.
To avoid this, try adding COMPILE_PARTIAL=true variable to your file watcher settings:
Also, make sure that Track only root files is off.
See the comments in https://youtrack.jetbrains.com/issue/WEB-13459

Configure Less with PhpStorm doesn't compile

I am trying to compile my styles.less to styles.css. My folder structure is following:
assets->less->styles.less
assets->css->styles.css
I believe my configurations are wrong. In PhpStorm I set less output path to refresh: ../css/$FileNameWithoutExtension$.css
I do have a styles.css file under the less file and it is compiling.
So far I only know regular CSS so I'm not very familiar with Less yet.
Any help?
Your File Watcher setup is incomplete.
Right now it will save the generated file next to the source... but you need it 2 folders up.
You did set up correctly in Output paths to refresh .. but that file tells IDE what file to check when file watcher is finished running. It is not where the generated file will be placed.
You need to alter your Arguments field.
Currently you have ... $FileName$ $FileNameWithoutExtension$.css ...
You need to adjust the path there -- it has to be ... $FileName$ ../../css/$FileNameWithoutExtension$.css ... -- because that's where you specify such path.
(leading and trailing "..." means other parameters that you have got there)
You should have changed the Arguments field accordingly;
Like:
Arguments: --no-color $FileName$ $ProjectFileDir$/themes/elisa/assets/css/$FileDirPathFromParent(less)$$FileNameWithoutExtension$.css
Output paths to refresh: $ProjectFileDir$/themes/elisa/assets/css/$FileDirPathFromParent(less)$$FileNameWithoutExtension$.css

load script from other file extension?

is it possible to load module from file with extension other than .lua?
require("grid.txt") results in:
module 'grid.txt' not found:
no field package.preload['grid.txt']
no file './grid/txt.lua'
no file '/usr/local/share/lua/5.1/grid/txt.lua'
no file '/usr/local/share/lua/5.1/grid/txt/init.lua'
no file '/usr/local/lib/lua/5.1/grid/txt.lua'
no file '/usr/local/lib/lua/5.1/grid/txt/init.lua'
no file './grid/txt.so'
no file '/usr/local/lib/lua/5.1/grid/txt.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './grid.so'
no file '/usr/local/lib/lua/5.1/grid.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
I suspect that it's somehow possible to load the script into package.preaload['grid.txt'] (whatever that is) before calling require?
It depends on what you mean by load.
If you want to execute the code in a file named grid.txt in the current directory, then just do dofile"grid.txt". If grid.txt is in a different directory, give a path to it.
If you want to use the path search that require performs, then add a template for .txt in package.path, with the correct path and then do require"grid". Note the absence of suffix: require loads modules identified by names, not by paths.
If you want require("grid.txt") to work should someone try that then yes, you'll need to manually loadfile and run the script and put whatever it returns (or whatever require is documented to return when the module doesn't return anything) into package.loaded["grid.txt"].
Alternatively, you could write your own loader just for entries like this which you set into package.preload["grid.txt"] which finds and loads/runs the file or, more generically, you could write yourself a loader function, insert it into package.loaders, and then let it do its job whenever it sees a "*.txt" module come its way.