When I use the comment shortcut (Ctrl + /) the slashes are placed at the beginning of the line, like this:
protected function before()
{
// echo "(before) ";
}
However I'd expect this behaviour:
protected function before()
{
//echo "(before) ";
}
How do I configure PhpStorm to use the latter approach?
Settings/Preferences
Editor | Code Style | PHP
Other tab and uncheck Line comments at first column option
In modern versions it is now located at the Code Generation tab:
PhpStorm 2018.3 and newer:
File -> Settings (Ctrl + Alt + S)
Editor -> Code Style -> PHP
(tab) Code Generation -> Comment Code -> (uncheck) Line comment at first column
Related
I've recently upgraded to neovim 0.5.0, and I've been experimenting at replacing older syntax and indenting plugins with treesitter. I'm having some problems getting things to work correctly when editing YAML files.
I have the following in my init.lua file:
local ts = require 'nvim-treesitter.configs'
ts.setup {ensure_installed = 'maintained',
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
disable = {"python", }
},
}
Running :checkhealth reports
health#nvim_treesitter#check
========================================================================
[...]
## Parser/Features H L F I J
[...]
- yaml ✓ ✓ ✓ ✓ ✓
But when I create a YAML file, for example...
- hosts: foo<RETURN>
...then the cursor ends up at column 0 on the following line, rather
than indented as required. This behaviors persists for the rest of the
file: regardless of the YAML syntax, the cursor always goes to column 0
on return
I know that treesitter indent support is considered "experimental". Is
this just broken right now, or do I have something misconfigured?
Looks like the YAML parser's indentations are pretty rudimentary: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/yaml/indents.scm
You may have a better development experience by just disabling tree-sitter indentation for just yaml and using the default Vim regex indentation instead.
In your nvim-treesitter config
require('nvim-treesitter.configs').setup {
indent = {
enable = true,
disable = { 'yaml' }
}
}
Issue
Following is a minimal, contrived example:
read :: FilePath -> Aff String
read f = do
log ("File: " <> f) -- (1)
readTextFile UTF8 f -- (2)
I would like to do some debug logging in (1), before a potential error on (2) occurs. Executing following code in Spago REPL works for success cases so far:
$ spago repl
> launchAff_ $ read "test/data/tree/root.txt"
File: test/data/tree/root.txt
unit
Problem: If there is an error with (2) - file is directory here - , (1) seems to be not executed at all:
$ spago repl
> launchAff_ $ read "test/data/tree"
~/purescript-book/exercises/chapter9/.psci_modules/node_modules/Effect.Aff/foreign.js:532
throw util.fromLeft(step);
^
[Error: EISDIR: illegal operation on a directory, read] {
errno: -21,
code: 'EISDIR',
syscall: 'read'
}
The original problem is more complex including several layers of recursions (see E-Book exercise 3), where I need logging to debug above error.
Questions
How can I properly log regardless upcoming errors here?
(Optional) Is there a more sophisticated, well-established debugging alternative - purescript-debugger? A decicated VS Code debug extension/functionality would be the cherry on the cake.
First of all, the symptoms you observe do not mean that the first line doesn't execute. It does always execute, you're just not seeing output from it due to how console works in the PureScript REPL. The output gets swallowed. Not the only problem with REPL, sadly.
You can verify that the first line is always executed by replacing log with throwError and observing that the error always gets thrown. Or, alternatively, you can make the first line modify a mutable cell instead of writing to the console, and then examine the cell's contents.
Finally, this only happens in REPL. If you put that launchAff_ call inside main and run the program, you will always get the console output.
Now to the actual question at hand: how to debug trace.
Logging to console is fine if you can afford it, but there is a more elegant way: Debug.trace.
This function has a hidden effect - i.e. its type says it's pure, but it really produces an effect when called. This little lie lets you use trace in a pure setting and thus debug pure code. No need for Effect! This is ok as long as used for debugging only, but don't put it in production code.
The way it works is that it takes two parameters: the first one gets printed to console and the second one is a function to be called after printing, and the result of the whole thing is whatever that function returns. For example:
calculateSomething :: Int -> Int -> Int
calculateSomething x y =
trace ("x = " <> show x) \_ ->
x + y
main :: Effect Unit
main =
log $ show $ calculateSomething 37 5
> npx spago run
'x = 37'
42
The first parameter can be anything at all, not just a string. This lets you easily print a lot of stuff:
calculateSomething :: Int -> Int -> Int
calculateSomething x y =
trace { x, y } \_ ->
x + y
> npx spago run
{ x: 37, y: 5 }
42
Or, applying this to your code:
read :: FilePath -> Aff String
read f = trace ("File: " <> f) \_ -> do
readTextFile UTF8 f
But here's a subtle detail: this tracing happens as soon as you call read, even if the resulting Aff will never be actually executed. If you need tracing to happen on effectful execution, you'll need to make the trace call part of the action, and be careful not to make it the very first action in the sequence:
read :: FilePath -> Aff String
read f = do
pure unit
trace ("File: " <> f) \_ -> pure unit
readTextFile UTF8 f
It is, of course, a bit inconvenient to do this every time you need to trace in an effectful context, so there is a special function that does it for you - it's called traceM:
read :: FilePath -> Aff String
read f = do
traceM ("File: " <> f)
readTextFile UTF8 f
If you look at its source code, you'll see that it does exactly what I did in the example above.
The sad part is that trace won't help you in REPL when an exception happens, because it's still printing to console, so it'll still get swallowed for the same reasons.
But even when it doesn't get swallowed, the output is a bit garbled, because trace actually outputs in color (to help you make it out among other output), and PureScript REPL has a complicated relationship with color:
> calculateSomething 37 5
←[32m'x = 37'←[39m
42
In addition to Fyodor Soikin's great answer, I found a variant using VS Code debug view.
1.) Make sure to build with sourcemaps:
spago build --purs-args "-g sourcemaps"
2.) Add debug configuration to VS Code launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"runtimeArgs": ["-e", "require('./output/Main/index.js').main()"],
"smartStep": true // skips files without (valid) source map
}
]
}
Replace "./output/Main/index.js" / .main() with the compiled .js file / function to be debugged.
3.) Set break points and step through the .purs file via sourcemap support.
I have a set like below.
php55MajorVersion=5.5
php55MinorVersion=5
php55Dir="${top_build_dir}/php/php-${php55MajorVersion}.${php55MinorVersion}-${ansdkBuild}"
php56MajorVersion=5.6
php56MinorVersion=6
php56Dir="${top_build_dir}/php/php-${php56MajorVersion}.${php56MinorVersion}-${ansdkBuild}"
php70MajorVersion=7.0
php70MinorVersion=4
php70Dir="${top_build_dir}/php/php-${php70MajorVersion}.${php70MinorVersion}-${ansdkBuild}"
Then I have the following input
phpVersion="php70"
phpMajorVersion="${phpVersion}MajorVersion"
phpMinorVersion="${phpVersion}MinorVersion"
phpDir="${phpVersion}Dir"
Now I want to print value associated with phpMajorVersion , which should be 7.0 (how -> phpMajorVersion -> ${phpVersion}MajorVersion -> php70->MajorVersion -> 7.0).
I have tried using $("${phpVersion}MajorVersion"), but am still getting , php70MajorVersion , but not 7.0 .
Any pointers on this?
You can get what you want using the getProperty method like this:
ext {
php55MajorVersion=5.5
php56MajorVersion=5.6
php70MajorVersion=7.0
phpVersion="php70"
}
println getProperty("${phpVersion}MajorVersion")
I believe it's not possible to achieve this using just braces, another StackOverflow answer suggests the same.
i am trying to move plot results in to rmarkdown in R studio
the following code fails
```{r front_stuff ,echo=FALSE,fig.height=3,fig.width=4}
library(ggplot2)
library(cowplot)
library(lubridate)
library(reshape2)
library(htmlTable)
library(data.table)
library(png)
project_folder<-"C:\\Users\\jciconsult\\SkyDrive\\trial_retail\\"
load(paste0(project_folder,"sa_prov_html.RSave"))
load(paste0(project_folder,"Ontario_plot_save.RSave"))
ls()
```
`r ggdraw(cow_plot1)`
Error message is
Quitting from lines 29-29 (test1.Rmd)
Error in vapply(x, format_sci_one, character(1L), ..., USE.NAMES = FALSE) :
values must be length 1,
but FUN(X[[1]]) result is length 2
Calls: ... paste -> hook -> .inline.hook -> format_sci -> vapply
Execution halted
If I take the same code and copy it into a clear R session (eliminating the stuf for code blocks), everything works.
What I am trying to do is get a document that can convert to word. I am using the knit HTML option because that is needed to get my htmlTable output to work.
I want something that I can cut and paste into word for final formatting,
The plot cannot be drawn because it is inline code. Try using a code chunk instead:
```{r}
ggdraw(cow_plot1)
```
Also, the proper way to set a working directory with knitr (which seems to be what you want to achieve) is with the knitr option root.dir:
library(knitr)
opts_knit$set(root.dir = project_folder)
load("sa_prov_html.RSave")
load("Ontario_plot_save.RSave")
Like the title says,I would like to develop vala with vim.My productivity is badly affected due to the lack Taglist plugin support for vala.
I found a ctags implementation in valide,
http://bazaar.launchpad.net/~valide/valide/trunk/files/head:/ctags-vala/
Can anyone guide me how to make this ctag implemention work with Taglist or some other vim plugin which works for vala
Found the answer,
set this is .vimrc
let tlist_vala_settings='c#;d:macro;t:typedef;n:namespace;c:class;'.
\ 'E:event;g:enum;s:struct;i:interface;'.
\ 'p:properties;m:method'
I did have the same needs, and I found this site :
http://sophiaongnome.wordpress.com/2012/01/31/how-do-i-set-up-my-vala-ide-in-vim/
The guy uses Tagbar in Vim, and anjuta-ctags which implement ctags for Vala.
I give you also my Vim configuration for Vala:
set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
map <leader><F2> :lvimgrep! <cword> /usr/share/vala-0.16/vapi/*<CR> :lopen <CR>
set complete+=k/home/marc/.vim/syntax/vala.vim
set isk+=(
" Disable valadoc syntax highlight
"let vala_ignore_valadoc = 1
" Enable comment strings
let vala_comment_strings = 1
" Highlight space errors
let vala_space_errors = 1
" Disable trailing space errors
"let vala_no_trail_space_error = 1
" Disable space-tab-space errors
let vala_no_tab_space_error = 1
" Minimum lines used for comment syncing (default 50)
"let vala_minlines = 120
let g:tagbar_ctags_bin="anjuta-tags"
set iskeyword+=.