Skip to content

Adjusted syntax highlighting and indentation - #9

Open
m455 wants to merge 1 commit into
jaawerth:mainfrom
m455:m455/syntax-and-indentation-adjustments
Open

Adjusted syntax highlighting and indentation#9
m455 wants to merge 1 commit into
jaawerth:mainfrom
m455:m455/syntax-and-indentation-adjustments

Conversation

@m455

@m455 m455 commented Feb 2, 2025

Copy link
Copy Markdown

Highlighting adjustments:

  • Added period (.) to the iskeyword list in ftplugin/fennel.vim so things like string.match are highlighted, instead of just the string in string.match
  • Moved FennelSpecialForm out of the Special highlight group into the Define highlight group to semantically match what elements in this group do--They often define things (local, fn, etc.)
  • Moved LuaSpecialValue out of the Special highlight group into the Function highlight group since a lot of these are just Lua functions you can interop with

Indentation adjustments:

  • Removed do and if from lispwords to match indentation of fnlfmt
  • Removed if (do wasn't in here, so I didn't need to remove it) from g:fennel_fuzzy_indent_patterns to match formatting of fnlfmt

Minor formatting/consistency changes:

  • Added missing $ to the ends of some of the regex strings in g:fennel_fuzzy_indent_patterns
  • Reformatted g:fennel_fuzzy_indent_patterns list
  • Consolidated/combined some regex strings in g:fennel_fuzzy_indent_patterns into one regex string

Examples of what the changes in this PR will do:

if statement indentation changes from this:

(if thing1
  thing2
  thing3)

to this:

(if thing1
    thing2
    thing3)

do statement indentation changes from this:

(do (thing1)
  (thing2)
  (thing3))

to this:

(do (thing1)
    (thing2)
    (thing3))

Built-in Lua functions now highlight both sides of the period infix, so the highlighting changes from the following (where characters above each ^ are highlighted):

(io.write "hello there")
 ^^
 |
 only highlights 'io'

to this:

(io.write "hello there")
 ^^^^^^^^
 |
 highlights 'io.write'

Highlighting adjustments:

- Added period (.) to the 'iskeyword' list in ftplugin/fennel.vim so
  things like 'string.match' are highlighted, instead of just the
  'string' in 'string.match'
- Moved FennelSpecialForm out of the 'Special' highlight group into the
  'Define' highlight group to semantically match what elements in this
  group do--They often define things ('local', 'fn', etc.)
- Moved LuaSpecialValue out of the 'Special' highlight group into the
  'Function' highlight group since a lot of these are just Lua functions
  you can interop with

Indentation adjustments:

- Removed 'do' and 'if' from 'lispwords' to match indentation of fnlfmt
- Removed 'if' ('do' wasn't in here, so I didn't need to remove it) from
  g:fennel_fuzzy_indent_patterns to match formatting of fnlfmt

Minor formatting/consistency changes:

- Added missing '$' to the ends of some of the regex strings in g:
  fennel_fuzzy_indent_patterns
- Reformatted g:fennel_fuzzy_indent_patterns list
- Consolidated/combined some regex strings in
  g:fennel_fuzzy_indent_patterns into one regex string

Examples of what the changes in this PR will do:

'if' statement indentation changes from this:

(if thing1
  thing2
  thing3)

to this:

(if thing1
    thing2
    thing3)

'do' statement indentation changes from this:

(do (thing1)
  (thing2)
  (thing3))

to this:

(do (thing1)
    (thing2)
    (thing3))

Built-in Lua functions now highlight both sides of the period infix, so
the highlighting changes from the following (where characters above each
'^' are highlighted):

(io.write "hello there")
 ^^
 |
 only highlights 'io'

to this:

(io.write "hello there")
 ^^^^^^^^
 |
 highlights 'io.write'
@jaawerth

jaawerth commented Feb 7, 2025

Copy link
Copy Markdown
Owner

Thanks for this! I should have a chance to review this weekend. As you noted in chat, I'll just need to check whether anything is intentional (and thus should be configurable).

My bad on some of it - I actually have some changes I've been using locally that I thought I had already pushed, including the changes to lispwords! Might have saved you some trouble, but either way it's good you submitted this so I finally noticed that the plugin was lagging...

@m455

m455 commented Feb 28, 2025

Copy link
Copy Markdown
Author

@jaawerth Thanks man! And no rush :) Feel free to push to this PR with your intended changes! I'm not the most knowledgeable with this stuff, and it seems like what highlight groups people use for various vim plugins is inconsistent, so anything to make it a nicer experience while making it idiomatic with how vim highlight groups, lispwords, etc. should be!

And no worries, it took me like 2 years to finally make this PR hahaha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants