Skip to content

Setting the syntax wont be overwritten by :write - #1443

Merged
fischerling merged 7 commits into
martanne:masterfrom
Nomarian:syncdev
Nov 11, 2026
Merged

fischerling merged 7 commits into
martanne:masterfrom
Nomarian:syncdev

Conversation

@Nomarian

@Nomarian Nomarian commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

See each commit for info, they're all mostly aesthetic changes

A couple of keys added, file.syntax which holds the syntax, basically what Detect() returns
file.basename, which holds the... basename of the file, this is used because the :new :w file.ext is currently running on each :w, which means if you :set syntax to something else its gonna immediately reset it back to whatever it detects.

Also added a vis.theme because... well I don't know why there isn't, there should be a vis.theme

@Nomarian Nomarian changed the title lua/ updates Setting the syntax wont be overwritten by :write Nov 8, 2026

@fischerling fischerling left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I highly appreciate those changes, because the current behavior of setting syntax unconditionally on write is really annoying.

However I dislike the type annotation convention used.
But my personal taste is not enough to reject this.

Additionally, I see no reason why we shouldn't export the theme as vis.theme.

Comment thread lua/plugins/filetype.lua Resolved
Comment thread lua/plugins/filetype.lua Resolved
Comment thread lua/plugins/filetype.lua Resolved
@Nomarian

Nomarian commented Nov 8, 2026 via email •

Copy link
Copy Markdown
Contributor Author

@rnpnr rnpnr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with everything here in general but maybe keep the vis.theme stuff out. It should probably go to vis.options.theme but if there is some issue preventing that then it should wait until that is fixed.

@Nomarian

Nomarian commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

I'm fine with everything here in general but maybe keep the vis.theme stuff out. It should probably go to vis.options.theme but if there is some issue preventing that then it should wait until that is fixed.

Yes, you cannot set/use .options.theme, then vis.theme shall be removed?

@fischerling

Copy link
Copy Markdown
Collaborator

Frankly I'm not too fond of it, but it does force me to annotate the function completely and if a parameter changes I cannot ignore it like I do with ldoc.

I see your point.

But, this annotation is not recognized by the lua language server.
However, LDoc comments are not recognized either.

This is the hover I get for the Detect function:

--- hover: /home/muhq/code/vis/lua/plugins/filetype.lua: 456, 16 ---
```lua
function Detect(file: any)
  -> string
 ```

---
 Returns syntax/filetype
 utility -> datap -> filename -> extension -> L.detect() -> mime
 mime is supposed to be the most correct, but it execs file
 Which is slow and semi non-portable, so its left for last
 string: lexer --

Using an LDoc comment I get this:

--- hover: /home/muhq/code/vis/lua/plugins/filetype.lua: 456, 16 ---
```lua
function Detect(file: any)
  -> string
```

---

 Returns syntax/filetype
 utility -> datap -> filename -> extension -> L.detect() -> mime
 mime is supposed to be the most correct, but it execs file
 Which is slow and semi non-portable, so its left for last

 @tparam FILE file the file to detect the lexer for.
 @tparam string the detected lexer for the file

@Nomarian
Nomarian force-pushed the syncdev branch 3 times, most recently from 75cdeac to 59eba0d Compare November 9, 2026 15:32
@fischerling

fischerling commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

LGTM. Will merge it tomorrow if @rnpnr has nothing against it.

@Nomarian

Nomarian commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

I'll squash some commits for less history but it should all be functionally the same.

@fischerling

Copy link
Copy Markdown
Collaborator

But, this annotation is not recognized by the lua language server. However, LDoc comments are not recognized either.

I figured out what kind of type annotations lua-languauge-server supports:
https://github.com/LuaLS/lua-language-server/wiki/Annotations

--- Some function
---@param string foo some parameter
local function bar(foo)
	return foo
end

This annotation does result in a proper Hover message:

--- hover: /home/muhq/foo.lua: 7, 8 ---
```lua
function bar(foo: string)
  -> string
```

---

 Return stuff.

@*param* `foo` — some parameter

@Nomarian

Nomarian commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

@fischerling interestingly, ldoc supports having comments on the parameters like I was already doing, the return still needs @return outside the function, but ldoc says that 3 or more dashes --- starts a new section but lua ls seems to use it... so that's confusing, I also cannot test, given that I use neither, I might use ldoc, but I already tried and failed to install lls already, so supporting it will be up to you

I also have 4 more PRs planned from my development branch https://github.com/Nomarian/vis/tree/dev/lua

https://stevedonovan.github.io/ldoc/manual/doc.md.html

@fischerling
fischerling merged commit 8e6ec6d into martanne:master Nov 11, 2026
12 checks passed
@Nomarian
Nomarian deleted the syncdev branch November 11, 2026 16:31
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.

3 participants