kristijanhusak / vim-dadbod-ui

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

column width in dbout is too large #47

Closed tejeshreddymeka closed 4 years ago

tejeshreddymeka commented 4 years ago

Screenshot from 2020-06-30 17-37-35

kristijanhusak commented 4 years ago

dbout output is completely handled by vim-dadbod. I'm not sure if this can be configured somehow. @pnetherwood do you maybe have some advice how to reduce width of the columns for mssql?

Autocompletion only autocompletes tables,schemas and columns. It is not a full completion framework.

tejeshreddymeka commented 4 years ago

dbout output is completely handled by vim-dadbod. I'm not sure if this can be configured somehow. @pnetherwood do you maybe have some advice how to reduce width of the columns for mssql?

Autocompletion only autocompletes tables,schemas and columns. It is not a full completion framework.

OK.

Thanks for the quick reply.

tejeshreddymeka commented 4 years ago

I came to know that in vim-dadbod the raw output from sqlcmd tool is printing into to dbout (in the case of mssql).
Should i have to write some parsing function on my own the can parse the dbout content or is there any other way ?

By the way @kristijanhusak , your vim-dadbod-ui is owesome.

kristijanhusak commented 4 years ago

You should be able to provide custom width for columns. Check this comment: https://github.com/kristijanhusak/vim-dadbod-ui/pull/26#issuecomment-622968185

And this SO question: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b6f2314c-1ecb-43fc-b881-2d2df7c9c457/setting-individual-column-width-in-sqlcmd-outut?forum=sqltools

I think combining these two should help you solve the issue.

tejeshreddymeka commented 4 years ago

Thanks for the links. I am able to configure the columns width.

pnetherwood commented 4 years ago

sqlcmd will size the columns based on the field width up to a maximum (default 80) but only if it knows how long the field is. If you do some manipulation in the select statement it won't know how big the field is and will set it to the maximum. That's what's happening with the output of sp_help (which is why I added the Columns item in vim-dadbod-ui so it all fit nicely on the screen) Its possible to pass parameters to sqlcmd "under the covers" using a an ini file. Search google for SQLCDMINI.

tejeshreddymeka commented 4 years ago

@pnetherwood Yeah I have set ‘SQLCMDINI’ to use ‘init.sql’ which contains :setvar SQLCMDCOLSEP "|"

:setvar SQLCMDMAXFIXEDTYPEWIDTH 20

:setvar SQLCMDMAXVARTYPEWIDTH 50

There is another option that we can usesqlcmd -W which remove trailing spaces in each column and it best fits to the screen. But I’m not able to find the var that I need to set to get that functionality.

May I know which var I need to set to get best column width to fit nicely to the screen.

pnetherwood commented 4 years ago

I don't know if they're is one. Certainly not according to this list: https://docs.microsoft.com/en-us/sql/ssms/scripting/sqlcmd-use-with-scripting-variables?view=sql-server-ver15#sqlcmd-scripting-variables

On Tue, 30 Jun 2020, 21:46 tejeshreddy, notifications@github.com wrote:

@pnetherwood https://github.com/pnetherwood Yeah I have set ‘SQLCMDINI’ to use ‘init.sql’ which contains :setvar SQLCMDCOLSEP "|"

:setvar SQLCMDMAXFIXEDTYPEWIDTH 20

:setvar SQLCMDMAXVARTYPEWIDTH 50

There is another option that we can usesqlcmd -W which remove trailing spaces in each column and it best fits to the screen. But I’m not able to find the var that I need to set to get that functionality.

May I know which var I need to set to get best column width to fit nicely to the screen.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kristijanhusak/vim-dadbod-ui/issues/47#issuecomment-652034197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2VNBZVEBOQVRIJBDCHZRDRZJFL7ANCNFSM4OMF7FNQ .

tejeshreddymeka commented 4 years ago

Ok thank you.

0re5ama commented 1 month ago

:setvar SQLCMDCOLSEP "|"

:setvar SQLCMDMAXFIXEDTYPEWIDTH 20

:setvar SQLCMDMAXVARTYPEWIDTH 50

I am facing the same issue and I don't know how to set these. Do I set it in the connection string? Or do I set it in my lazygit configuration of dadbod-ui? Also, init.sql doesn't look like an sql file