zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.37k stars 1.16k forks source link

Added Syntax Highlighting for nftables-firewall config file #3325

Open theredcmdcraft opened 1 month ago

theredcmdcraft commented 1 month ago

Created nftables syntax highlighting

niten94 commented 3 weeks ago

Sorry, I do not know much about nftables syntax and syntax highlighting so I cannot review much. There is nothing else I can properly suggest but the header pattern is still at least not changed.

theredcmdcraft commented 3 weeks ago

Oh sorry, i didn`t see the "suggested change". I thought it had already been changed.

theredcmdcraft commented 1 week ago

Sorry, I do not know much about nftables syntax and syntax highlighting so I cannot review much. There is nothing else I can properly suggest but the header pattern is still at least not changed.

Can someone else check the code? Or can you merge it simply?

niten94 commented 6 days ago

Can someone else check the code? Or can you merge it simply?

I cannot merge pull requests but I tried reviewing again. I do not know much about syntax highlighting so I think it is better if another person reviews a bit. I think not adding all expressions and merging may be fine for now.

I looked at nft(8) manpage as a reference but I think reading it may be confusing when not looking at the wiki first.

theredcmdcraft commented 6 days ago

It may look weird if groups in IPv6 addresses with hex digits are not highlighted but integers can be highlighted using this rule:

    - constant.number: "\\b([1-9][0-9]*|0[0-7]*|0[Xx][0-9A-Fa-f]+)\\b"

There is a lot of expressions in nftables but the keywords suggested are usually used so it may be fine highlighting them only for now.

i think we must not check everything at the first time. there is also a tool called nft. with the command nft -c -f <path to file> you can check the nftables syntax before you restart the service. this will prompt you if there is an error in your config file.