Commit Graph
1350 Commits
Author SHA1 Message Date
Jaehwang Jung aa16590999 docs(lua): number → integer (#22517) 2023-03-04 13:07:39 +00:00
Jaehwang Jung 82b77900d7 docs(diagnostic): number → integer (#22512) 2023-03-04 13:06:20 +00:00
Jaehwang Jung 1f07307aeb docs(inspect): number → integer (#22511) 2023-03-04 13:05:46 +00:00
Jaehwang Jung ccd2cc1abd docs(uri): number → integer (#22515) 2023-03-04 13:05:16 +00:00
Jaehwang Jung 6a20c29dcd docs(filetype): number → integer (#22516) 2023-03-04 13:05:01 +00:00
Jaehwang Jung 128b82103b docs(treesitter): number → integer (#22513) 2023-03-04 13:04:05 +00:00
Gregory Anders bf90ceb548 fix(treesitter): break early from loop when match is found (#22499)
Fixup to #22484.
2023-03-03 07:52:57 -07:00
Justin M. Keyes 8414cfe7f4 docs: fix vim.treesitter tags
Problem:
Help tags like vim.treesitter.language.add() are confusing because
`vim.treesitter.language` is (thankfully) not a user-facing module.

Solution:
Ignore the "fstem" when generating "treesitter" tags.
2023-03-03 15:07:23 +01:00
Christian Clason 74c9c413e7 Merge pull request #22484 from gpanders/inspect-tree-fix-cursor
fix(treesitter): maintain cursor position when toggling anonymous nodes
2023-03-03 14:19:09 +01:00
Jaehwang Jung f0a2ffab29 fix(treesitter): typos in _range.lua
fix(treesitter): typos _range.lua
2023-03-03 11:05:59 +00:00
Lewis Russell 6d4f481821 fix(treesitter): disallow empty filetypes
Fixes #22473
2023-03-03 09:44:02 +00:00
Amaan Qureshi fdb6b4d2e7 vim-patch:9.0.1368: Bass files are not recognized (#22485)
Problem:    Bass files are not recognized.
Solution:   Add patterns for Bass files. (Amaan Qureshi, closes vim/vim#12088)

https://github.com/vim/vim/commit/4ed914b18a47192f79f342bea5e8f59e120d5260
2023-03-02 23:29:03 +01:00
Gregory Anders 86ff239240 refactor(treesitter): use string.format to create lines 2023-03-02 14:15:18 -07:00
Gregory Anders 2eeafc43c4 fix(treesitter): maintain cursor position when toggling anonymous nodes
When toggling anonymous nodes in the :InspectTree window, keep the
cursor fixed relative to the node within the tree. This prevents the
cursor from jumping.
2023-03-02 14:11:15 -07:00
Christian Clason f449121764 feat(treesitter): add :InspectTree command (#22477) 2023-03-02 18:03:11 +01:00
Justin M. Keyes b0b4c31097 refactor: rename show_tree => inspect_tree #22474
Problem:
"show" is potentially a new verb that we can avoid (there is already
"open" and "echo"). Even if we can't avoid it, the behavior of
`show_tree` fits well in the "inspect" family of functions: a way for
users to introspect/reflect on the state of Nvim.

Existing "inspect" functions:
    vim.inspect()
    vim.inspect_pos()
    vim.treesitter.inspect_language()
    nvim__inspect_cell

Solution:
Rename `show_tree` to `inspect_tree`.
2023-03-02 07:01:42 -08:00
Mike bc15b075d1 feat(vim.fs): pass path to find() predicate, lazy evaluate #22378
Problem:
No easy way to find files under certain directories (ex: grab all files under
`test/`) or exclude the content of certain paths (ex. `build/`, `.git/`)

Solution:
Pass the full `path` as an arg to the predicate.
2023-03-01 08:51:22 -08:00
Gregory Anders 014981c900 fix(lsp): only fire LspDetach for attached buffers (#22468)
If the LSP server fails to start then the client never initializes and
thus never calls its on_attach function and an LspAttach event is
never fired. However, the on_exit function still fires a LspDetach
event, so user autocommands that attempt to "clean up" in LspDetach may
run into problems if they assume that the buffer was already attached.

The solution is to only fire an LspDetach event if the buffer was
already attached in the first place.
2023-03-01 17:47:56 +01:00
Mathias Fußenegger 896d672736 fix(lsp): use buffer scheme for files not stored on disk (#22407)
Sending `didOpen` with a `file` scheme causes problems with some
language servers because they expect the file to exist on disk.

See https://github.com/microsoft/language-server-protocol/pull/1679
2023-03-01 15:33:13 +01:00
Jens Claes 96d3616a53 fix(lsp): callHierarchy methods also require the callHierarchyProvider (#22427) 2023-03-01 11:35:16 +01:00
bfredl 011b4c5c62 Merge pull request #22452 from folke/master
fix(inspect): always resolve full treesitter lang hl groups
2023-02-28 14:13:01 +01:00
bfredl 7e19cabeb1 perf(lsp): only redraw the windows containing LSP tokens
redraw! redraws the entire screen instead of just the windows with
the buffer which were actually changed.

I considered trying to calculating the range for the delta
but it looks tricky. Could a follow-up.
2023-02-28 13:11:36 +01:00
Folke Lemaitre 7574d58304 fix(inspect): alwasy resolve full treesitter lang hl groups 2023-02-28 12:12:08 +01:00
Mike f89e3497c8 docs(lsp): update cmd_env description (#22438) 2023-02-27 21:19:41 +01:00
Amaan Qureshi 2a8e6a2f1a vim-patch:9.0.1360: Cue files are not recognized (#22439)
Problem:    Cue files are not recognized.
Solution:   Add patterns for Cue files. (Amaan Qureshi, closes vim/vim#12067)

https://github.com/vim/vim/commit/80c5b2c0f78b24e52c73bb162dda3ad85acd7e82
2023-02-27 21:08:31 +01:00
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
Jason Hansen bdf6d8733e fix(lsp): wrong format of bufnr and client order in error message (#22336) 2023-02-21 07:24:47 +01:00