vim-dadbod-ui icon indicating copy to clipboard operation
vim-dadbod-ui copied to clipboard

`set list` in ftplugin is overriden for query files

Open ss-raicangu opened this issue 6 months ago • 2 comments

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.

  • Was this a deliberate choice?
  • If so, would you please consider allowing the override of some of these options 🙏 ?

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

  • NVIM v0.10.0, Build type: Release, LuaJIT 2.1.1720049189
  • vim-dadbod-ui: 0f51d8d (Merge pull request 263 from ArkadyBuryakov/master, 2024-07-22).

Checklist

  • [x] I have searched past issues: list is:issue and ftplugin is:issue
  • [x] I have followed git-blame: 310e57e (Adding initial files., 2020-03-20).

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 avatar Aug 05 '24 08:08 ss-raicangu