Highlighting mode for emacs and vim

Moderators: cyao, michael_borland

blanco-garcia
Posts: 68
Joined: 29 Oct 2021, 10:41

Highlighting mode for emacs and vim

Post by blanco-garcia » 22 Dec 2021, 02:56

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
Attachments
elegant.vim.txt
(9.79 KiB) Downloaded 151 times
elegant.el.txt
(23.37 KiB) Downloaded 137 times

michael_borland
Posts: 1927
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Highlighting mode for emacs and vim

Post by michael_borland » 07 Jan 2022, 15:29

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

blanco-garcia
Posts: 68
Joined: 29 Oct 2021, 10:41

Re: Highlighting mode for emacs and vim

Post by blanco-garcia » 24 Jan 2022, 04:35

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

blanco-garcia
Posts: 68
Joined: 29 Oct 2021, 10:41

Re: Highlighting mode for emacs and vim

Post by blanco-garcia » 20 Apr 2022, 09:25

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.
Attachments
elegant-vim-v0.3.zip
vim autocompletion v0.3
(109.43 KiB) Downloaded 130 times

michael_borland
Posts: 1927
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Highlighting mode for emacs and vim

Post by michael_borland » 23 May 2022, 12:47

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

blanco-garcia
Posts: 68
Joined: 29 Oct 2021, 10:41

Re: Highlighting mode for emacs and vim

Post by blanco-garcia » 30 May 2022, 04:08

great !

o

soliday
Posts: 390
Joined: 28 May 2008, 09:15

Re: Highlighting mode for emacs and vim

Post by soliday » 01 Jun 2022, 14:26

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.

blanco-garcia
Posts: 68
Joined: 29 Oct 2021, 10:41

Re: Highlighting mode for emacs and vim

Post by blanco-garcia » 13 Oct 2022, 01:59

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
Attachments
elegant.nanorc.txt
(7.26 KiB) Downloaded 45 times

michael_borland
Posts: 1927
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Highlighting mode for emacs and vim

Post by michael_borland » 20 Oct 2022, 12:52

Thanks for posting this.

--Michael

blanco-garcia
Posts: 68
Joined: 29 Oct 2021, 10:41

Re: Highlighting mode for emacs and vim

Post by blanco-garcia » 08 Nov 2022, 03:58

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
Attachments
elegant.lang.txt
(4.8 KiB) Downloaded 46 times

Post Reply