diff --git a/README.md b/README.md index d000daf..fd919db 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ If there are duplicate connection names from same source, warning will be shown ## Settings -An overview of all settings and their default values can be found at `:help vim-dadbod-ui`. +An overview of all settings and their default values can be found at `:help vim-dadbod-ui`. ### Table helpers Table helper is a predefined query that is available for each table in the list. @@ -290,6 +290,7 @@ let g:db_ui_disable_mappings = 1 " Disable all mappings let g:db_ui_disable_mappings_dbui = 1 " Disable mappings in DBUI drawer let g:db_ui_disable_mappings_dbout = 1 " Disable mappings in DB output let g:db_ui_disable_mappings_sql = 1 " Disable mappings in SQL buffers +let g:db_ui_disable_mappings_javascript = 1 " Disable mappings in Javascript buffers (for Mongodb) ``` ## Toggle showing postgres views in the drawer diff --git a/autoload/db_ui.vim b/autoload/db_ui.vim index 6971c7a..e549a93 100644 --- a/autoload/db_ui.vim +++ b/autoload/db_ui.vim @@ -428,6 +428,10 @@ function! s:dbui.populate_schema_info(db) abort let a:db.quote = get(scheme_info, 'quote', 0) let a:db.default_scheme = get(scheme_info, 'default_scheme', '') let a:db.filetype = get(scheme_info, 'filetype', db#adapter#call(url, 'input_extension', [], 'sql')) + " Properly map mongodb js to javascript + if a:db.filetype ==? 'js' + let a:db.filetype = 'javascript' + endif endfunction " Resolve only urls for DBs that are files diff --git a/doc/dadbod-ui.txt b/doc/dadbod-ui.txt index adbf2a1..9bfd648 100644 --- a/doc/dadbod-ui.txt +++ b/doc/dadbod-ui.txt @@ -645,6 +645,16 @@ g:db_ui_disable_mappings_sql If this is set to `1`, no default mappings for SQL buffers are defined. + Default value: `0` + + *g:db_ui_disable_mappings_javascript* +g:db_ui_disable_mappings_javascript + If this is set to `1`, no default mappings for Javascript buffers + are defined. + Note that these mappings are set only when buffer is created + with vim-dadbod-ui, to not interfere with default javascript + behavior. + Default value: `0` *g:db_ui_bind_param_pattern* diff --git a/ftplugin/javascript.vim b/ftplugin/javascript.vim new file mode 100644 index 0000000..6ebdb63 --- /dev/null +++ b/ftplugin/javascript.vim @@ -0,0 +1,8 @@ +if get(g:, 'db_ui_disable_mappings', 0) || get(g:, 'db_ui_disable_mappings_javascript', 0) || get(b:, 'dbui_db_key_name', '') == '' + finish +endif + +call db_ui#utils#set_mapping('W', '(DBUI_SaveQuery)') +call db_ui#utils#set_mapping('E', '(DBUI_EditBindParameters)') +call db_ui#utils#set_mapping('S', '(DBUI_ExecuteQuery)') +call db_ui#utils#set_mapping('S', '(DBUI_ExecuteQuery)', 'v') diff --git a/plugin/db_ui.vim b/plugin/db_ui.vim index 0f63676..3dc178c 100644 --- a/plugin/db_ui.vim +++ b/plugin/db_ui.vim @@ -18,6 +18,7 @@ let g:db_ui_disable_mappings = get(g:, 'db_ui_disable_mappings', 0) let g:db_ui_disable_mappings_dbui = get(g:, 'db_ui_disable_mappings_dbui', 0) let g:db_ui_disable_mappings_dbout = get(g:, 'db_ui_disable_mappings_dbout', 0) let g:db_ui_disable_mappings_sql = get(g:, 'db_ui_disable_mappings_sql', 0) +let g:db_ui_disable_mappings_javascript = get(g:, 'db_ui_disable_mappings_javascript', 0) let g:db_ui_table_helpers = get(g:, 'db_ui_table_helpers', {}) let g:db_ui_auto_execute_table_helpers = get(g:, 'db_ui_auto_execute_table_helpers', 0) let g:db_ui_show_help = get(g:, 'db_ui_show_help', 1)