nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
14.98k stars 818 forks source link

Preview does not apply any syntax highlighting for Fortran files #2772

Open miEsMar opened 8 months ago

miEsMar commented 8 months ago

Description

When searching files, seraching by grep (or every other Telescope command), if file is a Fortran file preview does not apply any syntax highlight, just plain text.

Neovim version

NVIM v0.9.2
Build type: RelWithDebInfo
LuaJIT 2.1.1694082368

Operating system and version

Win 10 Pro version 10.0.19045 N/D build 19045

Telescope version / branch / rev

telescope 0.1.x

checkhealth telescope

==============================================================================
telescope: require("telescope.health").check()

Checking for required plugins ~
- OK plenary installed.
- WARNING nvim-treesitter not found. 

Checking external dependencies ~
- OK rg: found ripgrep 13.0.0 (rev af6b6c543b)
- WARNING fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities

===== Installed extensions ===== ~

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Steps to reproduce

  1. Simply add a Fortan file to a given project tree, and verify that highlighting is not shown in preview.

Expected behavior

Syntex highlighting in Telescope preview for Fortran files.

Actual behavior

Preview shows Fortran files as plain text, no syntax highlight.

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('telescope').setup()
  require('telescope').load_extension('fzf')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
jamestrew commented 8 months ago

I don't know enough fortran to tell what I'm seeing lol

This is foo.f opened in with the min config image

Same config, same file in telescope image ^ this looks like it has syntax highlighting but looks totally different from the other one above

Can you elaborate some more?

miEsMar commented 8 months ago

Hi @jamestrew , thanks for getting back.

What you're seeing is: when opening the buffer normally in (Neo)Vim, the fortran.vim syntax file detects the fixed file format since the file has the .f extension. So, all those red highlighting at the beginning of each line is because for it that's an error, cause all syntactical lines should begin at the 7th column onwards (the first 6 column characters are reserved for labels and other things).

On the other hand, it's funny how instead Telescope preview highlights it using the free file format, which is what happens to be actually used, regardless of the .f file extension.

This is what I have instead (extension: .f90):

File rendered as buffer

immagine

File previewed from Telescope

immagine

NOTE: this is what I have instead if I change with .f file extension: immagine

miEsMar commented 8 months ago

The only way for me to get it to work is by setting .f77 as file extension: immagine