spywhere / detect-language.nvim

neovim plugin for better language auto-detection, powered by tree-sitter
52 stars 0 forks source link

doesnt work with lua files #9

Closed olivertzeng closed 5 months ago

olivertzeng commented 5 months ago

Should instead make an exclusion list of filetypes you want to disable and also make it available in opts={} as well

disabled_filetypes = { "help", "text", "markdown" },

it's mainly because i sometimes have .bak backup files with source code and want to have treesitter enabled in them as well.

and also you'll probably never see a [No Name] file if you use a startpanel plugin like dashboard.nvim

related: #1

spywhere commented 5 months ago

I don't quite understand the title of this issue. Does this mean enabling auto-detection for all files (with and without a file type) and excluding only specific file types?

Currently, auto-detection is enabled unless

I think what you are looking for is for It's a buffer that already has a file type set by anything but auto-detection to be configurable in a way that would allow/disallow certain file types to be auto-detected. Do I understand this correctly?

Also, when you open a .bak file, what file type does it set for you? From my reproduction, this returns no file type and gets auto-detected correctly.

Additionally, it is worth noting that this plugin will only set a file type listed in a configuration and supported by a tree-sitter.

olivertzeng commented 5 months ago

Also, when you open a .bak file, what file type does it set for you? From my reproduction, this returns no file type and gets auto-detected correctly.

for instance if i open a .bak file with lua code itll not enable treesitter and other stuff

i supposed that it only enables when opening a noname file

olivertzeng commented 5 months ago

圖片

olivertzeng commented 5 months ago

this is a file called escape without filename

olivertzeng commented 5 months ago

with that code

-- lua, default settings
require("better_escape").setup({
    mapping = { "jj" }, -- a table with mappings to use
    timeout = vim.o.timeoutlen, -- the time in which the keys must be hit in ms. Use option timeoutlen by default
    clear_empty_lines = true, -- clear line after escaping if there is only whitespace
    keys = "<Esc>", -- keys used for escaping, if it is a function will use the result everytime
})

doing :DetectLanguage shows me

[Detect-Language] Too many possible languages, try write some code

olivertzeng commented 5 months ago

oh wait it just doesn't work for lua ill change the title

spywhere commented 5 months ago

Hmm... I cannot reproduce using your file.

https://github.com/spywhere/detect-language.nvim/assets/1087399/a868f3de-b362-4a0c-bb44-86529f1af459

Here all the configuration I used for testing

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.rtp:prepend(lazypath)

require("lazy").setup({
  'nvim-treesitter/nvim-treesitter',
  {
    'spywhere/detect-language.nvim',
    config = true
  }
})
olivertzeng commented 5 months ago

Hmm... I cannot reproduce using your file. LuaTesting.mov

Here all the configuration I used for testing

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.rtp:prepend(lazypath)

require("lazy").setup({
  'nvim-treesitter/nvim-treesitter',
  {
    'spywhere/detect-language.nvim',
    config = true
  }
})

it works

alright it seems that it's my other plugin's issues, closing