kristijanhusak / vim-dadbod-ui

Simple UI for https://github.com/tpope/vim-dadbod
MIT License
1.54k stars 94 forks source link

`set list` in ftplugin is overriden for query files #267

Open ss-raicangu opened 3 months ago

ss-raicangu commented 3 months ago

Description

Very niche problem, so thanks in advance for even considering πŸ˜… .

I rely on list-mode characters a fair bit to avoid invisible errant whitespace but DBUI query files setlocal nolist, which I couldn't override with a after/ftplugin/mysql.lua file.

To reproduce

  1. Create after/ftplugin/mysql.vim.
    setlocal list
  2. Open a DBUI query file.
  3. Check that list is disabled.
    verbose set list?
    " nolist
    "     Last set from ~/.local/share/nvim/site/pack/ssraicangu/opt/dadbod_ui/autoload/db_ui/query.vim line 170

Setup

Checklist

Possible solution

diff --git a/autoload/db_ui/query.vim b/autoload/db_ui/query.vim
index 7aae57b..96ce0f9 100644
--- a/autoload/db_ui/query.vim
+++ b/autoload/db_ui/query.vim
@@ -167,7 +167,7 @@ function! s:query.setup_buffer(db, opts, buffer_name, was_single_win) abort
   endif

   if &filetype !=? a:db.filetype || !is_existing_buffer
-    silent! exe 'setlocal filetype='.a:db.filetype.' nolist noswapfile nowrap nospell modifiable'
+    silent! exe 'setlocal nolist noswapfile nowrap nospell modifiable filetype='.a:db.filetype
   endif
   let is_sql = &filetype ==? a:db.filetype
   nnoremap <silent><buffer><Plug>(DBUI_EditBindParameters) :call <sid>method('edit_bind_parameters')<CR>

Ref 1. Setting filetype after nolist seems to load the preference from the ftplugin file.

I'm open to creating a pull request, if desired πŸ™‚ .

ss-raicangu commented 3 months ago

Sorry, accidentally submitted too early. Have finished posting issue now.

kristijanhusak commented 3 months ago

You can set up a PR that removes it. I don't remember why I added it.