Page 1 of 2

Highlighting mode for emacs and vim

Posted: 22 Dec 2021, 02:56
by blanco-garcia
Dear all,

I have created a highlighting mode for Elegant .ele (commands) and .lte (lattice) files to help myself with file edition.
I leave them here in case they are of any use for someone else.

VIM
https://github.com/orblancog/elegant-vim

EMACS
https://github.com/orblancog/elegant-mode

Best regards,

o

Re: Highlighting mode for emacs and vim

Posted: 07 Jan 2022, 15:29
by michael_borland
Thanks, those are useful.

I'm thinking about how we can generate these automatically when elegant is updated. Also, if there's a way to inform emacs or vi about the parameters available for each element or namelist, that would be even better.

--Michael

Re: Highlighting mode for emacs and vim

Posted: 24 Jan 2022, 04:35
by blanco-garcia
Dear Michael,

great to here it is of any help for someone else.

The highlighting file, as it is now, could be easily generated automatically having as input the list of words that could be read by a string editor, ( maybe awk to be sure it runs on any platform, or, emacs-lisp or Julia to contribute with the usage of high performace codes ). For this first release of the highlighting files I have done it manually, which also forces me to learn few things about Elegant on the process.

If I am to include the parameters available for each element to achieve something like auto-completion I'm sure it will be better to use a library ... I'll have a look in february.

Best regards,
o

Re: Highlighting mode for emacs and vim

Posted: 20 Apr 2022, 09:25
by blanco-garcia
Dear Michael, dear all,

I have a solution for the autocompletion in vim, at the moment only using vimscripting in VIM 8.2 so it should be compatible with other vim versions.

I show how to use it in https://github.com/orblancog/elegant-vim/, however, I leave here V0.3.

USAGE
a) To autocomplete commands, type in vim while in insert mode :

Code: Select all

& CTRL+X CTRL+o
it will display a list of available commands. One could also autocomplete a partially written command name, e.g.

Code: Select all

&tune CTRL+X CTRL+o
which shows a smaller list of matching command names.

b) To autocomplete parameters, type in vim while in insert mode :

Code: Select all

CTRL+X CTRL+u
it will display a list of available parameters for the closest command starting with &.

INSTALLATION:
It is a painful manual installation of 4 files and edition of one more, be patient and from a terminal copy the following files in the following folders :

Code: Select all

cd ~/.vim/syntax/
wget https://raw.githubusercontent.com/orblancog/elegant-vim/main/syntax/elegant.vim
cd ~/.vim/ftdetect/
wget https://raw.githubusercontent.com/orblancog/elegant-vim/main/ftdetect/elegant.vim
cd ~/.vim/autoload/
wget https://raw.githubusercontent.com/orblancog/elegant-vim/main/autoload/elegantcomplete.vim
cd ~/.vim/after/plugin/
wget https://raw.githubusercontent.com/orblancog/elegant-vim/main/after/plugin/elegant.vim
If any of the folders does not exist, you must create it.

Last, add to your ~/.vimrc file

Code: Select all

syntax on
set omnifunc=syntaxcomplete#Complete

Sorry for the incovinience, I will check for any other installation method.


Best regards, and let me know of any problems.
Over the time I will add the element parameters, it will go slowly as there are a lot.

Re: Highlighting mode for emacs and vim

Posted: 23 May 2022, 12:47
by michael_borland
Thanks for the update.

We'll look into how we can generate the configuration automatically from the code, using your files as a template. That should also allow us to install everything when the code is installed.

--Michael

Re: Highlighting mode for emacs and vim

Posted: 30 May 2022, 04:08
by blanco-garcia
great !

o

Re: Highlighting mode for emacs and vim

Posted: 01 Jun 2022, 14:26
by soliday
I have a script that searches the code for the highlightable elements and commands and updates the configuration files you made. The resulting files will be in the elegant/editors/ directory with the next release with instructions on how to install them for emacs and vim.

Re: Highlighting mode for emacs and vim

Posted: 13 Oct 2022, 01:59
by blanco-garcia
Dear all,

a colleague of mine uses the text editor nano,
https://www.nano-editor.org/
so, I created a minimal syntax highlighting that I would like to share. The syntax file is attached to this message.

Instructions :
1) Download it and remove the '.txt' from the name
2) Copy elegant.nanorc to ~/.nano/
3) Create a file ~/.nanorc with the following line

Code: Select all

include "~/.nano/elegant.nanorc"
I leave also the link to my repository in github:
https://github.com/orblancog/elegant-nano

best regards,
o

Re: Highlighting mode for emacs and vim

Posted: 20 Oct 2022, 12:52
by michael_borland
Thanks for posting this.

--Michael

Re: Highlighting mode for emacs and vim

Posted: 08 Nov 2022, 03:58
by blanco-garcia
New colleagues prefer to edit files in gedit.

I have created a first version of the gedit elegant syntax highlight to make comments and commands easy to see.
I attach to this message the syntax file.

To install it, check your gtksource version, download the elegant.lang.txt file and remove the ".txt" at the end :
put in ~/.local/share/gtksourceview-2.0/language-specs/elegant.lang
or in ~/.local/share/gtksourceview-3.0/language-specs/elegant.lang

Best regards,
o