Plain emacs' make-mode indents a multi line variable in a counterintuitive way:
define SOURCE_DIRS =
utils
utils/string
utils/stream
tools
tools/config
tools/io
endef
A more intiuitive and clear indentation would be:
define SOURCE_DIRS =
utils
utils/string
utils/stream
tools
tools/config
tools/io
endef
Can emacs/make-mode be configured to produce the desired indentation?
Related
I'm editing GML files (GameMaker Studio) in VSCode. There's a wonderful plugin, GML Support which adds autocomplete for inbuilt GML functions and instances variables along with a bunch of other cool things.
However, VSCode doesn't seem to recognise local variables in GML (see screen grab below. Dot notation works fine)
I had a look at the VSCode's Programmatic Language Extension for variable name auto-completion but still don't get how I could register the variable declaration (i.e. var fooBar = 23;) with VSCode's Language Server.
Ideally, I'd like the Language Server to respect variable scope for GML files:
global variables - any var declarations for files under script folder
any local variable declarations - all var declarations in the surrounding {...}
What would be the easiest way to add variable name completion as described above?
Thanks in advance!
Edit: looked at vscode-python to see how registerCompletionItemProvider (based on VSCode Language Extension doco) could be used. Unfortunately, still not clear to me as vscode-python seem to rely on Jedi to provide symbols?
So any points appreciated!
If you want to enable simple auto-completion, you can add the following to your settings.json (Command Palette ➜ Open Settings (JSON)):
"[gml-gms81]": { "editor.quickSuggestions": true },
"[gml-gms1]": { "editor.quickSuggestions": true },
"[gml-gms2]": { "editor.quickSuggestions": true },
which works for a workaround:
For a proper solution, well, you'll need to use the registerCompletionItemProvider and index the file on demand or as you go.
The official example demonstrates the use.
For intricacies of processing GML syntax, you can peck at the code in the Ace-based external editor that I made. Processing variable definitions specifically requires you to skip over strings, comments, and loop over values (var name[=value][, name2[=value2]]) with relative degree of confidence (which can be accomplished through a balanced parser).
I'm trying to use GNU Emacs 26.3 + AUCTeX 12.2.3 and it seems to work, but the colors it shows in the source code are very annoying, specially in amsmath environment such as align, because it uses only one color for the whole block. I would like to ignore auctex highlighting so the code looks the same as before installing auctex package, this is something like this: source code before AUCTeX
I deleted some strings like "align" from "Font Latex Math Environments" so it doesn't use the font locking for math environments, and now it looks like normal text: current source code
It's better that one color, yes, but there are several commands that doesn't highlight and I would like them to. (Not highlighted commands occurs outside the align too). Another option would be adding a generic alphabetic string next to \ as a keyword so it would be highlighted but I also don't know how to achieve this.
I am using manual folding to write perl programs. Here is a typical fold:
sub do_something # does something --{{{
{
# perl code here
} # --}}}
When folded, these four lines are displayed thus:
+-- 4 lines: sub do_something does something ----------------------------
In the folded version, the hash mark before the word "does" has disappeared. Why? If this is a feature, how can I disable it? As a workaround, I am writing 'sub do_something ## does something --{{{', but is there a clean way to get vim to just display what I have typed? (Maybe this has something to do with perl.vim?)
What gets displayed instead of the folded lines is controlled by the 'foldtext' option. By default, the internal foldtext() function is used. :help foldtext() explains:
The returned string looks like this:
+-- 45 lines: abcdef
The number of dashes depends on the foldlevel. The "45" is
the number of lines in the fold. "abcdef" is the text in the
first non-blank line of the fold. Leading white space, "//"
or "/*" and the text from the 'foldmarker' and 'commentstring'
options is removed.
As you see, this is a heuristic of Vim to reduce clutter. To turn that off:
You can clear 'commentstring'; it is only used to add manual fold markers (and some commenting plugins may rely on it as a fallback), by putting :setlocal commentstring= into ~/.vim/after/ftplugin/perl.vim.
You can write your own fold function (example and instructions at :help fold-foldtext), and install that, either globally or (like above alternative) only for the Perl filetype.
I use editorconfig with the emacs plugin.
I like it, especially since it can sync my preferences across editors, and allow project specific settings. But when I edit common lisp files in emacs the editorconfig seems to mess up SLIME's intelligent lisp-specific indentation. i.e. it always indents the same amount instead of using the appropriate indentation or alignment for the current form.
Is there any way to specify that I would prefer to use the SLIME indentation over the editorconfig indentation?
Also, does anyone know how editorconfig interacts with smart-tabs?
There was a bug in editorconfig for emacs. It is now fixed.
In order for it to work you should have something like the following in your .editorconfig file:
[*.{lisp,asd,el}]
indent_style = space
indent_size = none
tab_width = none
Someplace I saw a snippet of code which told vi to use soft tabs and set the size of a tab. If you put this snippet at the bottom of a source file, then vi would magically use those settings for that file.
What is the syntax and rules for including that snippet in a source file? Can emacs be made to use these settings as well?
You can put this in a comment in your source file:
ex: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
The comment syntax depends on the type of the source file.
For C/C++/Java, this would be:
// ex: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
For JSP, this would be:
<%-- ex: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: --%>
This works if it is placed at the beginning of the source file, but I'm not sure that this'll work if placed at the end of it too.
This will not work for emacs. There might be a different way of achieving the same for emacs.
Check out :h modeline.
Example:
/* vim: ai set sw=4 ts=4 */
See :h modelines for how many lines into a file Vim will check for modeline info. The default is to check the first 5 lines.
As far as I know, vi didn't have this capability. You're likely thinking of the modeline feature of Vim. There is similar functionality in emacs, where you can put local variables in the file.
Note that, at least in Vim, modelines have had a history of vulnerabilities. This is primarily due to problematic options being specifically blacklisted instead of only allowing a certain subset of variables to be set in modelines. I'd suggest using a plugin like securemodelines.
Put this in your C++ source file:
// vim: set ft=cpp
The modeline feature looks for the string "vim:" and then executes what follows. Note: this could open up potential exploits if you don't trust the files you are opening, so think twice before enabling this feature.
Okay, first of all, in real vi you do this in the .exrc file.
Second, use
set autoindent tabstop=8 shiftwidth=4
because otherwise vi will insert tabs it thinks are only 4 characters wide. The resulting text file will not look like it makes sense in any other editor.