Commit Graph
3361 Commits
Author SHA1 Message Date
Lewis Russell f64098a2df fix(treesitter): fixup for health 2023-02-27 15:33:18 +00:00
Lewis Russell 5aa37e20e0 fix(treesitter): ipairs -> pairs
Fixes: https://github.com/nvim-treesitter/nvim-treesitter/issues/4349
2023-02-27 15:01:09 +00:00
Lewis Russell da56f06037 fix(treesitter): remove virtual text from playground
Implement the range and lang annotations as comments instead
2023-02-27 10:49:19 +00:00
Lewis Russell 774e59f3f9 feat(treesitter): expand the API 2023-02-26 16:53:33 +00:00
Mathias Fußenegger c1514d7e67 fix(lsp): fix some type annotations (#22397) 2023-02-25 18:47:05 +01:00
Mathias Fussenegger f0f27e9aef Revert "feat(lsp): implement workspace/didChangeWatchedFiles (#21293)"
This reverts commit 5732aa706c.

Causes editor to freeze in projects with many watcher registrations
2023-02-25 11:17:28 +01:00
Jon Huhn 5732aa706c feat(lsp): implement workspace/didChangeWatchedFiles (#21293) 2023-02-25 10:07:18 +01:00
Christian ClasonandAmaan Qureshi 15cce77b38 vim-patch:9.0.1351: Dhall files are not recognized (#22393)
Problem:    Dhall files are not recognized.
Solution:   Add patterns for Dhall files. (Amaan Qureshi, closes vim/vim#12052)

https://github.com/vim/vim/commit/def5521752abefe12db8cc3111a3b205ad1ac929

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2023-02-24 17:50:37 +01:00
Christian ClasonandAmaan Qureshi 4297127f14 vim-patch:9.0.1350: CPON files are not recognized (#22392)
Problem:    CPON files are not recognized.
Solution:   Add patterns for CPON files. (Amaan Qureshi, closes vim/vim#12053)

https://github.com/vim/vim/commit/c2254764bcada43eea894eb5852a26d5ac5ca8b0

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2023-02-24 15:34:52 +01:00
Raphael 1803dadb20 refactor(lsp): remove deprecated code (#22389) 2023-02-24 12:55:50 +01:00
Lewis Russell c57af5d41c feat(treesitter)!: remove silent option from language.add()
Simply use `pcall` if you want to silence an error.
2023-02-24 09:50:59 +00:00
Amaan Qureshi 5e1308b7ca vim-patch:9.0.1348: Un-grammar files are not recognized (#22383)
Problem:    Un-grammar files are not recognized.
Solution:   Add patterns for Un-grammar files. (Amaan Qureshi, closes vim/vim#12034)

https://github.com/vim/vim/commit/44e08c1cf83f5a50f8b21613551304a6651c1161
2023-02-23 22:12:01 +01:00
Lewis Russell 3f35ebb14d fix(treesitter): fixup language invalidation (#22381) 2023-02-23 18:09:44 +00:00
Lewis Russell 1df3f5ec6a feat(treesitter): upstream foldexpr from nvim-treesitter 2023-02-23 17:05:20 +00:00
Christian ClasonandAmaan Qureshi 8c339aa04b vim-patch:9.0.1346: Starlark files are not recognized (#22380)
Problem:    Starlark files are not recognized.
Solution:   Add patterns for Starlark files. (Amaan Qureshi, closes vim/vim#12049)

https://github.com/vim/vim/commit/ca06b30073de22dc120b532e90fbee2a10ef9772

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2023-02-23 17:52:33 +01:00
Lewis Russell 75e53341f3 perf(treesitter): smarter languagetree invalidation
Problem:
  Treesitter injections are slow because all injected trees are invalidated on every change.

Solution:
    Implement smarter invalidation to avoid reparsing injected regions.

    - In on_bytes, try and update self._regions as best we can. This PR just offsets any regions after the change.
    - Add valid flags for each region in self._regions.
    - Call on_bytes recursively for all children.
       - We still need to run the query every time for the top level tree. I don't know how to avoid this. However, if the new injection ranges don't change, then we re-use the old trees and avoid reparsing children.

This should result in roughly a 2-3x reduction in tree parsing when the comment injections are enabled.
2023-02-23 15:19:52 +00:00
Mathias Fußenegger f140175564 refactor(lsp): remove workaround for missing bit module (#22373) 2023-02-23 13:35:46 +01:00
Christian Clason 6dfbeb0d99 docs: fix more treesitter parsing errors 2023-02-23 10:25:22 +01:00
Christian Clason 05de0f4fea docs(treesitter): fix parse errors 2023-02-23 10:24:15 +01:00
Justin M. Keyes 09b6a68c37 Merge #21428 docs: naming conventions, guidelines 2023-02-22 10:40:01 -05:00
Justin M. Keyes 6752f1005d docs: naming conventions, guidelines
close #21063
2023-02-22 16:23:49 +01:00
Gregory Anders 675826da63 refactor(treesitter): Add vim.treesitter.get_node() (#22360)
This function replaces both vim.treesitter.get_node_at_pos() and
vim.treesitter.get_node_at_cursor(). These two functions are similar
enough that they don't need separate interfaces. Even worse,
get_node_at_pos() returns a TSNode while get_node_at_cursor() returns a
string, so the two functions behave slightly differently.

vim.treesitter.get_node() combines these two into a more streamlined
interface. With no arguments, it returns the node under the cursor in
the current buffer. Optionally, it can accept a buffer number or a
position to get the node at a given position in a given buffer.
2023-02-22 08:01:08 -07:00
Christian ClasonandAmaan Qureshi d1b34b7458 vim-patch:9.0.1337: yuck files are not recognized (#22358)
Problem:    Yuck files are not recognized.
Solution:   Add a filetype pattern for yuck files. (Amaan Qureshi,
            closes vim/vim#12033)

https://github.com/vim/vim/commit/cfce5cf542db20c7beba5b4211c0ae3305a64a43

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2023-02-22 10:58:15 +01:00
Lewis Russell 8714a4009c feat(treesitter): add filetype -> lang API
Problem:

  vim.treesitter does not know how to map a specific filetype to a parser.

  This creates problems since in a few places (including in vim.treesitter itself), the filetype is incorrectly used in place of lang.

Solution:

  Add an API to enable this:

  - Add vim.treesitter.language.add() as a replacement for vim.treesitter.language.require_language().
    - Optional arguments are now passed via an opts table.
    - Also takes a filetype (or list of filetypes) so we can keep track of what filetypes are associated with which langs.
    - Deprecated vim.treesitter.language.require_language().
  - Add vim.treesitter.language.get_lang() which returns the associated lang for a given filetype.
  - Add vim.treesitter.language.register() to associate filetypes to a lang without loading the parser.
2023-02-21 17:09:18 +00:00
Lewis Russell 2d99830706 refactor(man): add type annotations 2023-02-21 12:19:09 +00:00
Jason Hansen bdf6d8733e fix(lsp): wrong format of bufnr and client order in error message (#22336) 2023-02-21 07:24:47 +01:00
Christian ClasonandMatthias Queitsch 2f64137974 vim-patch:9.0.1319: PRQL files are not recognized (#22319)
Problem:    PRQL files are not recognized.
Solution:   Add a filetype pattern for PRQL files. (Matthias Queitsch,
            closes vim/vim#12018)

https://github.com/vim/vim/commit/9de960ace0f017fcfeaf64a2f6492f0f88b11fdb

Co-authored-by: Matthias Queitsch <matthias.queitsch@mailbox.org>
2023-02-19 01:27:32 +01:00
Eduard Baturin f43fa301c1 fix(lsp): check if the buffer is a directory before w! it (#22289) 2023-02-18 07:43:59 +01:00
Lewis Russell a289e82142 fix(treesitter): make params optional 2023-02-15 12:26:07 +00:00
Justin M. Keyes 1539f71363 Merge #22214 move init_default_autocmds to lua 2023-02-14 19:13:12 -05:00
Jonas Strittmatter b518aceaa8 feat(filetype): fall back to file extension when matching from hashbang (#22140)
If nothing matched in match_from_hashbang, also check the file extension table.
For a hashbang like '#!/bin/env foo', this will set the filetype to 'fooscript'
assuming the filetype for the 'foo' extension is 'fooscript' in the extension
table.
2023-02-13 16:04:16 -07:00
Lewis Russell d359f7a533 Merge pull request #22191 from lewis6991/feat/playground_imp
feat(treesitter): playground improvements
2023-02-13 10:54:03 +00:00
Jonas StrittmatterandGregory Anders 9668c166e8 fix(filetype): make vim.filetype.match() work with contents only (#22181)
Co-authored-by: Gregory Anders <greg@gpanders.com>
2023-02-11 08:08:33 -07:00
glacambre c5b34fa554 refactor: move init_default_autocmds to lua
The original motivation for this change came from developping
https://github.com/neovim/neovim/pull/22159, which will require adding
more autocommand creation to Neovim's startup sequence.

This change requires lightly editing a test that expected no autocommand
to have been created from lua.
2023-02-11 14:02:17 +01:00
Lewis Russell 8a985d12dd fix(treesitter): don't trample parsers when filetype!=lang
This allows vim.treesitter.show_tree() to work on buffers where the
filetype does not match the parser language name e.g, bash/sh.
2023-02-10 16:15:56 +00:00
Lewis Russell f5bad01869 feat(treesitter): playground improvements
- Render node ranges as virtual text
- Set filettype=query. The virtual text is to avoid parsing errors.
- Make sure highlights text is always in view.
2023-02-10 16:15:55 +00:00
Christian ClasonandAmaan Qureshi 1ca4a8b1dd vim-patch:9.0.1291: Move language files are not recognized (#22162)
Problem:    Move language files are not recognized.
Solution:   Recognize Move language files. (Amaan Qureshi, closes vim/vim#11947)

https://github.com/vim/vim/commit/6642982beaf4f1f5164f0315a1b3e3c275156089

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2023-02-08 09:47:55 +01:00
Christian ClasonandAmaan Qureshi 8fbe75b3dd vim-patch:9.0.1288: FunC files are not recognized (#22153)
Problem:    FunC files are not recognized.
Solution:   Recognize FunC files. (Amaan Qureshi, closes vim/vim#11949)

https://github.com/vim/vim/commit/91deac45392fe93094b9c31403b1ae771dc71938

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2023-02-07 10:29:37 +01:00
Amaan Qureshi 1675f0e270 vim-patch:9.0.1282: Ron files are not recognized (#22132)
Problem:    Ron files are not recognized.
Solution:   Recognize Ron files. (Amaan Qureshi, closes vim/vim#11948)

https://github.com/vim/vim/commit/c8ef30bc2eaec956549510cd4b2efc96b7aee563
2023-02-06 10:01:17 +01:00
Mateusz Majewski 6c39edaa7e fix(health): iterate using ipairs correctly (#22119)
In a few places ipairs was used to iterate over elements of the array.
However, the first return value of ipairs was erronously used, which is
not the value, but rather the index. This would result in errors, for
instance when trying to retrieve a field from the value.
2023-02-06 12:24:00 +08:00
Lewis Russell 7963a160e9 Merge pull request #21548 from figsoda/transform-capture
feat(treesitter): allow capture text to be transformed
2023-02-05 21:31:30 +00:00
Christian ClasonandJanez Podhostnik 23e34fe534 vim-patch:9.0.1281: Cadence files are not recognized (#22130)
Problem:    Cadence files are not recognized.
Solution:   Recognize Cadence files. (Janez Podhostnik, closes vim/vim#11951)

https://github.com/vim/vim/commit/cb626a4692df7154be02b47d6089ec679e95cb44

Co-authored-by: Janez Podhostnik <janez.podhostnik@gmail.com>
2023-02-05 17:59:18 +01:00
figsoda 4c66f5ff97 feat(treesitter): respect metadata[id].range for offset! 2023-02-04 21:15:03 -05:00
figsoda e1d5ad1cb8 feat(treesitter): add metadata option for get_node_text 2023-02-04 21:15:03 -05:00
figsodaandLewis Russell bb8845340b feat(treesitter): allow capture text to be transformed
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2023-02-04 21:04:45 -05:00
Christian ClasonandAmaan Qureshi 4b9bb3a184 vim-patch:9.0.1278: go.work.sum files are not recognized (#22121)
Problem:    go.work.sum files are not recognized.
Solution:   Recognize go.work.sum files as the gosum filetype. (Amaan Qureshi,
            closes vim/vim#11940)

https://github.com/vim/vim/commit/4ad8ae8465e30df38dba31910f130891b16d38a0

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2023-02-04 16:05:45 +01:00
Lewis Russell 9a5678463c fix(treesitter): fix most diagnostics 2023-02-04 14:58:38 +00:00
Christian ClasonandAmaan Qureshi c05b3c3bbd vim-patch:9.0.1274: FIRRTL files are not recognized (#22102)
Problem:    FIRRTL files are not recognized.
Solution:   Add a pattern for FIRRTL files. (Amaan Qureshi, closes vim/vim#11931)

https://github.com/vim/vim/commit/685bf83b73d0fe6fd36bb2949bebd6aae66a139e

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2023-02-02 17:26:22 +01:00
Lewis Russell 9ce44a750c fix(man): use italics for <bs>_ (#22086)
fix(man): use italics for <bs>_

Even though underline is strictly what this should be. <bs>_ was used by
nroff to indicate italics which wasn't possible on old typewriters so
underline was used. Modern terminals now support italics so lets use
that now.

See:
- https://unix.stackexchange.com/questions/274658/purpose-of-ascii-text-with-overstriking-file-format/274795#274795
- https://cmd.inp.nsk.su/old/cmd2/manuals/unix/UNIX_Unleashed/ch08.htm
2023-02-01 17:21:42 +00:00
Christian ClasonandMark Skelton d63ad600e0 vim-patch:9.0.1268: .clangd and .stylelintrc files don't get a filetype (#22079)
Problem:    .clangd and .stylelintrc files don't get a filetype.
Solution:   Use yaml for .clangd and json for .stylelintrc files. (Mark
            Skelton, closes vim/vim#11916)

https://github.com/vim/vim/commit/9c51798a1f3b79ace5ae0551a8bb122025ac94ed

Co-authored-by: Mark Skelton <mdskelton99@gmail.com>
2023-02-01 10:08:50 +01:00