lukas-reineke / indent-blankline.nvim

Indent guides for Neovim
MIT License
4.27k stars 106 forks source link

when i turn off the treesitter, the indent-blankline doesnt work at all. #390

Closed lukas-reineke closed 2 years ago

lukas-reineke commented 2 years ago

This issue is fixed, you have a different problem. I suspect it is the same as #373

But, when i turn off the treesitter, the indent-blankline doesnt work at all.

image

Originally posted by @dhymasriyanto in https://github.com/lukas-reineke/indent-blankline.nvim/issues/142#issuecomment-1084969196

lukas-reineke commented 2 years ago

I created a new issue for this. It is not related to the other issue, and we don't need to spam the other users.

In your screenshot, the indentation is not consistent, and you are mixing tabs and spaces. Please first fix the code, if it still doesn't work then, post your config and the code that doesn't work, so I can reproduce it.

dhymasriyanto commented 2 years ago

Okey, I am sorry for spam.

When I fix the indentation, and still using treesitter it seems works.

image

So, is it a bug? Or do I just need to fix my code format to make the indent work?

lukas-reineke commented 2 years ago

It should work without treesitter as well.

If it doesn't, please tell me how to reproduce it.

dhymasriyanto commented 2 years ago

When I turn off treesitter, it become like this:

image

The rainbow indent doesnt work at all. But when i turn treesitter on, it is fine. But if the indent format is not consistent, so some character will dissappear.

And this is my init.vim config:

set nohlsearch
set nocompatible
set t_Co=256
set termguicolors
set relativenumber
set cursorline
set number
set updatetime=300
set laststatus=2
set shortmess+=c
set cmdheight=2
call plug#begin('~/.vim/plugged')
Plug 'wakatime/vim-wakatime'
Plug 'sheerun/vim-polyglot'
Plug 'lukas-reineke/indent-blankline.nvim'
"Plug 'windwp/nvim-ts-autotag', {'branch': 'main'}
Plug 'ap/vim-css-color'
"Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
"Plug 'Yggdroot/indentLine'
"Plug 'lukas-reineke/onedark.nvim'
Plug 'honza/vim-snippets'
Plug 'andweeb/presence.nvim', {'branch': 'main'}
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-fugitive'
Plug 'Konfekt/FastFold'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'itchyny/lightline.vim'
Plug 'vifm/vifm.vim'
Plug 'joshdick/onedark.vim', {'branch': 'main'}
"Plug 'olimorris/onedarkpro.nvim', {'branch': 'main'}
"Plug 'rmehri01/onenord.nvim', { 'branch': 'main' }
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files
Plug 'scrooloose/nerdcommenter'
Plug 'puremourning/vimspector'
Plug 'szw/vim-maximizer'
call plug#end()

"lua require('onedark').setup()
"colorscheme onedark
"colorscheme onedarkpro
"colorscheme onenord
source $HOME/.config/nvim/themes/onedark.vim

let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1

let g:lightline = {
  \ 'colorscheme': 'wombat',
  \ }

lua require('indent-blankline')
"lua <<EOF
"require'nvim-treesitter.configs'.setup {
  "ensure_installed = "all",
  "highlight = {
    "enable = true,
    "custom_captures = {
      "-- Highlight the @foo.bar capture group with the "Identifier" highlight group.
      "-- ["foo.bar"] = "Identifier",
    "},
    "-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    "-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    "-- Using this option may slow down your editor, and you may see some duplicate highlights.
    "-- Instead of true it can also be a list of languages
    "additional_vim_regex_highlighting = false,
  "},
  "incremental_selection = {
    "enable = true,
    "keymaps = {
      "init_selection = "gnn",
      "node_incremental = "grn",
      "scope_incremental = "grc",
      "node_decremental = "grm",
    "},
  "},
  "indent = {
    "enable = true
  "}
"}
"EOF

"lua require('nvim-ts-autotag').setup()

set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}

let g:vimspector_enable_mappings = 'HUMAN'
nmap <leader>dd :call vimspector#Launch()<CR>
nmap <leader>dx :call vimspector#Reset()<CR>
nmap <leader>de :VimspectorEval
nmap <leader>dw :VimspectorWatch
nmap <leader>do :VimspectorShowOutput

" Use `[g` and `]g` to navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)

" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>a  <Plug>(coc-codeaction-selected)

" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac  <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf  <Plug>(coc-fix-current)

" Run the Code Lens action on the current line.
nmap <leader>ql  <Plug>(coc-codelens-action)

" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>

function! s:show_documentation()
  if (index(['vim','help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
  else
    call CocAction('doHover')
  endif
endfunction

" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')

nmap <F2> <Plug>(coc-rename)

nmap <C-b> :NERDTreeToggle<CR>
nmap <C-_> <plug>NERDCommenterToggle<CR>
map <C-t> :bot sp term://zsh<CR>

nmap zuz <Plug>(FastFoldUpdate)
let g:fastfold_savehook = 1
let g:fastfold_fold_command_suffixes =  ['x','X','a','A','o','O','c','C']
let g:fastfold_fold_movement_commands = [']z', '[z', 'zj', 'zk']

let g:markdown_folding = 1
let g:tex_fold_enabled = 1
let g:vimsyn_folding = 'af'
let g:xml_syntax_folding = 1
let g:javaScript_fold = 1
let g:sh_fold_enabled= 7
let g:ruby_fold = 1
let g:perl_fold = 1
let g:perl_fold_blocks = 1
let g:r_syntax_folding = 1
let g:rust_fold = 1
let g:php_folding = 1

let g:NERDCustomDelimiters = { 'vue': { 'left': '<!--','right': '-->' } }

" General options
let g:presence_auto_update         = 1
let g:presence_neovim_image_text   = "The One True Text Editor"
let g:presence_main_image          = "neovim"
let g:presence_client_id           = "793271441293967371"
"let g:presence_log_level           = "debug"
let g:presence_debounce_timeout    = 10
let g:presence_enable_line_number  = 1
let g:presence_blacklist           = []
let g:presence_buttons             = 1

" Rich Presence text options
let g:presence_editing_text        = "Editing %s"
let g:presence_file_explorer_text  = "Browsing %s"
let g:presence_git_commit_text     = "Committing changes"
let g:presence_plugin_manager_text = "Managing plugins"
let g:presence_reading_text        = "Reading %s"
let g:presence_workspace_text      = "Working on %s"
let g:presence_line_number_text    = "Line %s out of %s"

" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()

"command! -nargs=0 Prettier :CocCommand prettier.formatFile

let g:NERDTreeGitStatusWithFlags = 1

let g:gitgutter_max_signs = -1

"let g:gitgutter_async=0

let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']

let NERDTreeShowHidden=1

let g:NERDTreeIgnore = ['^node_modules$']

let g:ultisnips_javascript = {
  \ 'keyword-spacing': 'always',
  \ 'semi': 'never',
  \ 'space-before-function-paren': 'always',
  \ }

let g:coc_global_extensions = [
  \ 'coc-snippets',
  \ 'coc-pairs',
  \ 'coc-tsserver',
  \ 'coc-eslint', 
  \ 'coc-json', 
  \ 'coc-java',
  \ '@yaegassy/coc-intelephense'
  \ ]
  "\ 'coc-phpls'
 "\ 'coc-prettier',

inoremap <silent><expr> <TAB>
      \ pumvisible() ? coc#_select_confirm() :
      \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
      \ <SID>check_back_space() ? "\<TAB>" :
      \ coc#refresh()

function! s:check_back_space() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

let g:coc_snippet_next = '<tab>'

" sync open file with NERDTree
" Check if NERDTree is open or active
function! IsNERDTreeOpen()        
  return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction

" Call NERDTreeFind if NERDTree is active, current window contains a modifiable
" file, and we're not in vimdiff
function! SyncTree()
  if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
    NERDTreeFind
    wincmd p
  endif
endfunction

augroup templates
  autocmd!
  autocmd BufRead *.py,*.h,*.html,*.java call s:ApplyTemplate()

  function! s:ApplyTemplate()
    if getfsize(expand('%')) == 0
      execute "0r ~/.config/nvim/templates/skeleton." . expand('%:e')
      execute "%s/__CLASS_NAME__/" . expand('%:t:r') . "/e"
    endif
  endfun
augroup END

" Highlight currently open buffer in NERDTree
" autocmd BufEnter * call SyncTree()
lukas-reineke commented 2 years ago

Remove the lua require('indent-blankline'). You don't need it, and the module is called indent_blankline anyway, this should give you an error. But other than that, everything looks okay. your config works fine for me.

dhymasriyanto commented 2 years ago

Okay, sorry for not include this file. Actually, the lua require('indent-blankline') will load file on /lua/indent-blankline.lua:

image

(This image i take when i turn off the treesitter)

lukas-reineke commented 2 years ago

Still can't reproduce it. Your config works for me.

dhymasriyanto commented 2 years ago

Okay, maybe I still can handle this with auto indent. Thanks for ur advise!

lukas-reineke commented 2 years ago

Closing because of inactivity

martin-braun commented 1 year ago

@lukas-reineke I use NvChad, and disabling TreeSitter will give me:

indent-blankline: nvim-treesitter not found. Context will not work

What is going on?

EDIT: I had to disable show_current_context and show_current_context_start, which was true by default in NvChad. :)