Giter VIP home page Giter VIP logo

Comments (26)

clason avatar clason commented on September 23, 2024

That is the expected behavior.

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

Sorry in the issue I forgot a few backticks. I edited it.

Shouldn't fenced code blocks work with INI?

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

Yes, and it does for me. Check :InspectTree (press I to show injected language names).

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

For that command I get:

(section) ; [1:1 - 5:0] markdown
 (fenced_code_block) ; [1:1 - 5:0] markdown
  (fenced_code_block_delimiter) ; [1:1 - 3] markdown
  (info_string) ; [1:4 - 6] markdown
   (language) ; [1:4 - 6] markdown
  (block_continuation) ; [2:1 - 0] markdown
  (code_fence_content) ; [2:1 - 4:0] markdown
   (block_continuation) ; [3:1 - 0] markdown
   (block_continuation) ; [4:1 - 0] markdown
  (fenced_code_block_delimiter) ; [4:1 - 3] markdown

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

Can you test the latest Neovim nightly? And do other languages work in injections?

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

I tested bash, sh, nu (nushell/tree-sitter-nu), js, py. Those seem to work fine.

I could test nightly later on. Does it only work for nightly?

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

No; it should just work as ini is the language name. Just trying to bisect the differences between my working setup and yours.

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

Sorry but where is your working setup? Do you have some Neovim config repo?

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

No, it's bog-standard; nothing special. Since you have the issue, you should try to create a minimal reproducible config I can test with nvim --clean -u test.lua.

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

And the ini parser is in fact installed properly? (Don't trust checkhealth; look for ini.so.)

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

(Your minimal config uses the standard lazy path so will likely conflict with your installed plugins. There's zero reason to use Lazy for a minimal repro -- just clone nvim-treesitter itself and add the path to rtp.)

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

(Sorry deleted the comment by accident before. A repost.)

Here's a minimal reproducible config for me. In init.lua:

local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

require('lazy').setup({
  'nvim-treesitter/nvim-treesitter',
  build = ':TSUpdate',
  config = function()
    local configs = require('nvim-treesitter.configs')

    configs.setup({
      ensure_installed = {
        'ini',
        'markdown',
        'javascript',
      },
      sync_install = false,
      highlight = { enable = true },
      indent = { enable = true },
    })
  end,
})

In foo.md:

```ini
[section]
foo = bar
```

```js
const foo = 1
```

I run this with:

$ /usr/bin/nvim --clean -u init.lua foo.md

A screenshot:

Screenshot_2024-04-03_03-14-28

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

(Your minimal config uses the standard lazy path so will likely conflict with your installed plugins. There's zero reason to use Lazy for a minimal repro -- just clone nvim-treesitter itself and add the path to rtp.)

I tried your suggestion. I cloned the repo to a temporary directory. Here's my new config file:

vim.opt.runtimepath:prepend("/run/user/1000/nvim/nvim-treesitter")

require("nvim-treesitter.configs").setup({
        ensure_installed = {
                "ini",
                "markdown",
                "markdown_inline",
                "javascript",
        },
        sync_install = false,
        highlight = {
                enable = true,
                additional_vim_regex_highlighting = false,
        },
})

The same thing occurs.

I see these .so files in /run/user/1000/nvim/nvim-treesitter/parser/:

  • ini.so
  • javascript.so
  • markdown_inline.so
  • markdown.so

from nvim-treesitter.

lucario387 avatar lucario387 commented on September 23, 2024

It also works for me, stable or nightly, so I think the problem is something else here

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

This happens to me even on Termux. INI seems to be the only language that doesn't work. Is there some way for me to dig deeper to see what the issue might be?

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

Yes, try to compile the parser manually and see if it works via tree-sitter CLI.

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

Do you mean the INI parser? INI files themselves do get parsed correctly, just not inside Markdown files as code blocks.

If you mean the Markdown parser do I need to incorporate https://github.com/nvim-treesitter/nvim-treesitter/blob/11a3584b81c3249d2b6279305aee1c7ad273985a/queries/markdown/injections.scm somehow?

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

Oh no I'm using the latest commit. I just linked that to make the link shorter. I fixed it.

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

I don't know what to tell you then; I have literally zero idea how the behavior you describe is possible.

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

This appears to be related to language aliases for me. I see some in

for ft, lang in pairs {
. javascriptreact, ecma, jsx don't work, when js and javascript do.

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

Hmmm. Can you try adding ini = "ini" to that list? Although that would be the reverse direction, and I don't see how that's relevant since you're not relying on an alias, ini being the actual language name.

Does dosini work in codeblocks for you?

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

Adding ini = "ini" doesn't work.

Neither dosini nor confini work. However for an ini code block, I do get dosini returned for metadata["injection.language"] in

metadata["injection.language"] = get_parser_from_markdown_info_string(injection_alias)
.

from nvim-treesitter.

clason avatar clason commented on September 23, 2024

Ah, ok. Yeah, that predicate has always been iffy. Can you try the injection queries from the main branch? (Might need Nvim nightly.)

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

I was always on the main branch, but not on Neovim nightly. I could try it, but the next Neovim v0.10 is gonna be released soon anyway.

Is the main branch compatible with Neovim stable? Although I'm confused why it works for you guys and not for me.

from nvim-treesitter.

lucario387 avatar lucario387 commented on September 23, 2024

main branch is only intended to be used with neovim 0.10+ onwards, so you're in a land of your own there

from nvim-treesitter.

stevenxxiu avatar stevenxxiu commented on September 23, 2024

Ah sorry I meant I was using master. I was a bit confused as there's both master and main. I just checked for a LazyGit update, and the commits it showed matches master.

from nvim-treesitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.