Creating custom minimap-titles grammar for .tex fiels - coffeescript

I've recently started using Atom for my LaTeX needs, and so far it's doing really well. I'm using a package called minimap to display the whole code as a scrollbar which is very helpful, but I can't get the minimap-titles package to work properly. The comments I'm getting are generated with the \* *\ markers as opposed to with the LaTeX comment characters %.
How would I go about adding a *.tex file extension to the list of files recognized by minimap-titles, and subsequently specify the delimiter grammar for it?

I've figured it out.
I've added the following code to the switch extension clause in the minimap-titles.coffee in lib.
when 'tex', 'cls'
commentStart = ''
commentEnd = ''
# add '% ' to the beginning of each line
art = art.replace /^/, "% "
art = art.replace /\n/g, "\n% "
You can edit the code by going to Settings > Packages > Minimap Titles > View Code.
In the hindsight it's pretty trivial actually.

Related

How to convert embedded CRLF codes to their REAL newlines in Vscode?

I searched everywhere for this, the problem is that the search criteria is very similar to other questions.
The issue I have is that file (script actually) is embedded in another file. So when I open the parent file I can see the script as massive string with several \n and \r\n codes. I need a way to convert these codes to what they should be so that it formats the code correctly then I can read said code and work on it.
Quick snippet:
\n\n\n\n\nlocal scriptingFunctions\n\n\n\n\nlocal measuringCircles = {}\r\nlocal isCurrentlyCheckingCoherency
Should covert to:
local scriptingFunctions
local measuringCircles = {}
local isCurrentlyCheckingCoherency
perform a Regex Find-Replace
Find: (\\r)?\\n
Replace: \n
If you don't need to reconvert from newlines to \n after you're done working on the code, you can accomplish the trick by simply pressing ctrl-f and substituting every occurrence of \n with a new line (you can type enter in the replace box by pressing ctrl-enter or shift-enter).
See an example ctrl-f to do this:
If after you're done working on the code you need to reconvert to \n, you can add an invisible char to the replace string (typing it like ctrl-enter invisibleChar), and after you're done you can re-replace it with \n.
There's plenty of invisible chars, but I'd personally suggest [U+200b] (you can copy it from here); another good one is [U+2800] (⠀), as it renders as a normal whitespace, and thus is noticeable.
A thing to notice is that recent versions of vscode will show a highlight around invisible chars, but you can easily disable it by clicking on Adjust settings and then selecting Exclude from being highlighted.
If you need to reenable highlighting in the future, you'll have to look for "editor.unicodeHighlight.allowedCharacters" in the settings.

Search text inside all files in all directories (and subdirectories) in project with SpaceVim

So I just started using Neovim/Spacevim, and it's so awesome!
I am still getting used to everything, since I have never used Vim or anything like that before.
My question revolves around searching for particular text in all the files of the currently open project.
I am using the nerdtree file manager, and I was wondering how I might search through all the files in the project for a specific string. Like if I wanted to search function thisExactFunction() throughout the currently open folder/directory, how would I go about doing that? The main goal is to have a list of all the files that contain this search string.
I have fzf installed (as well as ripgrep), but seem to be having trouble in searching for specific text inside of all files. I can only search for files themselves, or some other search that does not yield what I need.
Can anyone point me in the right direction...? Thanks!
Check out the Ggrep command that Fzf supplies - see this series of vim screencasts to see how to use vim's in built features (quickfix list populated by :vimgrep) to achieve the same using other grepping tools.
Custom functions
I have a function in my .vimrc that uses ag silver
searcher to search within all
the files in a directory (and any subdirectories). So if you install ag, this
should work:
" Ag: Start ag in the specified directory e.g. :Ag ~/foo
function! s:ag_in(bang, ...)
if !isdirectory(a:1)
throw 'not a valid directory: ' .. a:1
endif
" Press `?' to enable preview window.
call fzf#vim#ag(join(a:000[1:], ' '),
\ fzf#vim#with_preview({'dir': a:1}, 'right:50%', '?'), a:bang)
endfunction
" Ag call a modified version of Ag where first arg is directory to search
command! -bang -nargs=+ -complete=dir Ag call s:ag_in(<bang>0, <f-args>)
Bonus
Sometimes it's hard to find things in vim's help, so I also have a function
that uses the one above to interactively search the help docs. This can be nice
to hone in on the topic you want. Use :H for this function (as opposed to the
classic :h)
function! Help_AG()
let orig_file = expand(#%)
let v1 = v:version[0]
let v2 = v:version[2]
" search in the help docs with ag-silver-search and fzf and open file
execute "normal! :Ag /usr/share/vim/vim".v1.v2."/doc/\<CR>"
" if we opened a help doc
if orig_file != expand(#%)
set nomodifiable
" for some reason not all the tags work unless I open the 'real' help
" so get whichever help was found and open it through Ag
let help_doc=expand("%:t")
" open and close that help doc - now the tags will work
execute "normal! :tab :help " help_doc "\<CR>:q\<CR>"
endif
endfunction
" get some help
command! H :call Help_AG()

Content of tags is not getting on the same line after certain point & it is getting added to the next line . How to get that content on the same line?

I am coding HTML & CSS in VS Code IDE. I have installed & enabled the prettier extension for better readability of the code & auto-indentation. but my content of tags is not going beyond that certain point on the screen & it is getting added to the next line whenever I save my code by Ctrl +S (example: see the last paragraph tag). How to get that content on the same line?
You shouldn't use Prettier if you don't need this behavior. That's what Prettier does: splits lines that are too long. See here https://prettier.io/docs/en/index.html

Why does VS Code break my Markdown fenced code blocks?

I'm creating a markdown document with some CSharp code blocks. Here's a sample:
Next, it feeds the strings to the regular expression matcher to produce a sequence of matches.
```csharp
let patternMatch = azimuthEncoderRegex.Match(message)
```
In the editor, this seems to be working nicely, like so:
As you can see, the code is formatted as expected and shows up correctly formatted in the preview window (not shown).
Now, when I save my file, the above text instantly changes to this:
If I use search-and-replace to change all the code specifiers back, the same thing happens. This breaks the code formatting!! The entire file is also re-flowed to remove all the line breaks I put in (that may be a clue).
UPDATE: I noticed that all of the reference-style hyperlinks were also removed from the end of the document, causing data loss.
WTF? Why is VS-Code doing this? I've tried disabling the Markdown extensions and the same thing happens. Any ideas, please?
Resolved by a change in settings.json for VS Code:
{
"pandocFormat.command": "pandoc --standalone --atx-headers --wrap=auto --columns=80 -f markdown-auto_identifiers -t markdown-simple_tables-multiline_tables-grid_tables-auto_identifiers-fenced_code_attributes --reference-links"
}
Thanks and credit to monofon (the author of the VS Code extension, based on Pandoc) for steering me to this solution.

Unexpected 'INDENT' in CoffeeScript Example Code

As I was playing around for the first time with CoffeeScript, I ran in to a problem. In order to debug my problem, I tried replacing my whole file with one of the example bits of code from the coffee script site:
kids =
brother:
name: "Max"
age: 11
sister:
name: "Ida"
age: 9
However, when I try to compile that code, I get:
Error: In coffee/main.coffee, Parse error on line 3: Unexpected 'INDENT'
at Object.parseError (/usr/lib/coffeescript/parser.js:501:11)
at Object.parse (/usr/lib/coffeescript/parser.js:573:32)
at Object.compile (/usr/lib/coffeescript/coffee-script.js:23:22)
at /usr/lib/coffeescript/command.js:99:27
at /usr/lib/coffeescript/command.js:72:28
at fs:84:13
at node.js:773:9
In coffee/main.coffee, Parse error on line 3: Unexpected 'INDENT'
Since this is code from the CoffeeScript site, I assume the code itself isn't the problem. However, the compiler also seems to be working properly; if I compile:
a = 2
it generates a file with:
(function(){
var a;
a = 2;
})();
as expected. So in other words, the code is good, the compiler is good, and yet somehow I'm getting this Unexpected 'IDENT' error ... can anyone help me understand what is going on?
I am pretty sure this is a tabs-vs-spaces issue. Tell your editor not to convert spaces to tabs if it does that. Also, go through your code with the cursor and make sure it doesn't jump over blank areas.
The issue is that while normal editors see a tab as equivalent to two or four spaces, coffeescript sees it as one space, so the indentation gets messed up.
If this all doesn't help, make sure you have a recent coffeescript version, e.g. 1.1.0 or newer.
If you are using a JetBrains IDE (IntelliJ, PHPStorm, etc) the change of setting that worked for me is:
File > Settings > Project Settings > Code Style > CoffeeScript > Tabs
and Indents
Tick "Use tab character" & "Smart tabs"
Code is fine. Make sure you haven't messed up the whitespace (strange control chars showing as blanks, tabs or similar).
If you have the same problem, but your indentation is okay,
then you must be suffering from bug 2868.
Basically, the error is misleading. Check for indentation
errors in the required files.
When in Atom you can automatically convert tabs to spaces:
Packages > Whitespace > Convert Tabs to Spaces
You can resolve this two ways
1. IF using webstorm File->Default Settings as said above
2. Other workaround, is to use a different editor like Sublime, there u can press enter on earlier line and it will auto tab it for you with spaces