add dadbod
This commit is contained in:
		
							parent
							
								
									216b778236
								
							
						
					
					
						commit
						fe2729a100
					
				
							
								
								
									
										9
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										9
									
								
								init.lua
								
								
								
								
							| 
						 | 
				
			
			@ -198,6 +198,15 @@ require('lazy').setup({
 | 
			
		|||
        map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
 | 
			
		||||
      end,
 | 
			
		||||
    },
 | 
			
		||||
    config = function()
 | 
			
		||||
      require('gitsigns').setup {
 | 
			
		||||
        current_line_blame = true,
 | 
			
		||||
        current_line_blame_opts = {
 | 
			
		||||
          delay = 1000,
 | 
			
		||||
          virt_text_pos = 'eol',
 | 
			
		||||
        },
 | 
			
		||||
      }
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,9 @@ local function map(mode, lhs, rhs)
 | 
			
		|||
	vim.keymap.set(mode, lhs, rhs, { silent = true })
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- (conflict with <leader>pw) keep copied stuffs in the buffer when pasting it
 | 
			
		||||
-- map("n", "<leader>p", "\"_dP")
 | 
			
		||||
 | 
			
		||||
-- Save
 | 
			
		||||
map("n", "<leader>w", "<CMD>update<CR>")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ o.swapfile = false
 | 
			
		|||
 | 
			
		||||
-- Scrolling settings
 | 
			
		||||
o.scrolloff = 8
 | 
			
		||||
o.colorcolumn = '80'
 | 
			
		||||
o.colorcolumn = '120'
 | 
			
		||||
 | 
			
		||||
o.timeoutlen = 500
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,3 +45,8 @@ install requests
 | 
			
		|||
```
 | 
			
		||||
sudo apt install python3-requests
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
format json (require jq installed)
 | 
			
		||||
```
 | 
			
		||||
:%!jq .
 | 
			
		||||
```
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
return {
 | 
			
		||||
	"tpope/vim-dadbod",
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
return {
 | 
			
		||||
	"kristijanhusak/vim-dadbod-completion",
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,48 @@
 | 
			
		|||
return {
 | 
			
		||||
	"kristijanhusak/vim-dadbod-ui",
 | 
			
		||||
	dependencies = {
 | 
			
		||||
		{ 'tpope/vim-dadbod',                     lazy = true },
 | 
			
		||||
		{ 'kristijanhusak/vim-dadbod-completion', ft = { 'javascript' }, lazy = true },
 | 
			
		||||
	},
 | 
			
		||||
	ft = { 'javascript' },
 | 
			
		||||
	cmd = {
 | 
			
		||||
		'DBUI',
 | 
			
		||||
		'DBUIToggle',
 | 
			
		||||
		'DBUIAddConnection',
 | 
			
		||||
		'DBUIFindBuffer',
 | 
			
		||||
	},
 | 
			
		||||
	init = function()
 | 
			
		||||
		-- Your DBUI configuration
 | 
			
		||||
		vim.g.db_ui_use_nerd_fonts = 1
 | 
			
		||||
		vim.o.filetype = 'javascript'
 | 
			
		||||
	end,
 | 
			
		||||
	config = function()
 | 
			
		||||
		vim.keymap.set("n", '<leader>du', '<CMD>DBUIToggle<CR>')
 | 
			
		||||
		vim.keymap.set("n", '<leader>dl', '<CMD>DBUILastQueryInfo<CR>')
 | 
			
		||||
 | 
			
		||||
		vim.o.filetype = 'javascript'
 | 
			
		||||
		vim.api.nvim_create_autocmd("FileType", {
 | 
			
		||||
			pattern = {
 | 
			
		||||
				"javascript",
 | 
			
		||||
			},
 | 
			
		||||
			command = [[setlocal omnifunc=vim_dadbod_completion#omni]],
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		vim.api.nvim_create_autocmd("FileType", {
 | 
			
		||||
			pattern = {
 | 
			
		||||
				"sql",
 | 
			
		||||
				"javascript",
 | 
			
		||||
			},
 | 
			
		||||
			callback = function()
 | 
			
		||||
				vim.schedule(function()
 | 
			
		||||
					require("cmp").setup.buffer { sources = { { name = "vim-dadbod-completion" } } }
 | 
			
		||||
				end
 | 
			
		||||
				)
 | 
			
		||||
			end,
 | 
			
		||||
		})
 | 
			
		||||
-- nnoremap <silent> <leader>du :DBUIToggle<CR>
 | 
			
		||||
-- nnoremap <silent> <leader>df :DBUIFindBuffer<CR>
 | 
			
		||||
-- nnoremap <silent> <leader>dr :DBUIRenameBuffer<CR>
 | 
			
		||||
-- nnoremap <silent> <leader>dl :DBUILastQueryInfo<CR>
 | 
			
		||||
	end,
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -58,7 +58,7 @@ return {
 | 
			
		|||
        -- a string that defines the port to start delve debugger.
 | 
			
		||||
        -- default to string "${port}" which instructs nvim-dap
 | 
			
		||||
        -- to start the process in a random available port
 | 
			
		||||
        port = "${port}",
 | 
			
		||||
        port = "2345",
 | 
			
		||||
        -- additional args to pass to dlv
 | 
			
		||||
        args = {}
 | 
			
		||||
      },
 | 
			
		||||
| 
						 | 
				
			
			@ -66,26 +66,54 @@ return {
 | 
			
		|||
 | 
			
		||||
    -- Dap UI setup
 | 
			
		||||
    -- For more information, see |:help nvim-dap-ui|
 | 
			
		||||
       dapui.setup()
 | 
			
		||||
    -- dapui.setup {
 | 
			
		||||
    --   -- Set icons to characters that are more likely to work in every terminal.
 | 
			
		||||
    --   --    Feel free to remove or use ones that you like more! :)
 | 
			
		||||
    --   --    Don't feel like these are good choices.
 | 
			
		||||
    --   icons = { expanded = '▾', collapsed = '▸', current_frame = '*' },
 | 
			
		||||
    --   controls = {
 | 
			
		||||
    --     icons = {
 | 
			
		||||
    --       pause = '⏸',
 | 
			
		||||
    --       play = '▶',
 | 
			
		||||
    --       step_into = '⏎',
 | 
			
		||||
    --       step_over = '⏭',
 | 
			
		||||
    --       step_out = '⏮',
 | 
			
		||||
    --       step_back = 'b',
 | 
			
		||||
    --       run_last = '▶▶',
 | 
			
		||||
    --       terminate = '⏹',
 | 
			
		||||
    --       disconnect = "⏏",
 | 
			
		||||
    --     },
 | 
			
		||||
    --   },
 | 
			
		||||
    -- }
 | 
			
		||||
    -- dapui.setup()
 | 
			
		||||
    dapui.setup {
 | 
			
		||||
      -- Set icons to characters that are more likely to work in every terminal.
 | 
			
		||||
      --    Feel free to remove or use ones that you like more! :)
 | 
			
		||||
      --    Don't feel like these are good choices.
 | 
			
		||||
      icons = { expanded = '▾', collapsed = '▸', current_frame = '*' },
 | 
			
		||||
      controls = {
 | 
			
		||||
        icons = {
 | 
			
		||||
          pause = '⏸',
 | 
			
		||||
          play = '▶',
 | 
			
		||||
          step_into = '⏎',
 | 
			
		||||
          step_over = '⏭',
 | 
			
		||||
          step_out = '⏮',
 | 
			
		||||
          step_back = 'b',
 | 
			
		||||
          run_last = '▶▶',
 | 
			
		||||
          terminate = '⏹',
 | 
			
		||||
          disconnect = "⏏",
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
      -- Layouts define sections of the screen to place windows.
 | 
			
		||||
      -- The position can be "left", "right", "top" or "bottom".
 | 
			
		||||
      -- The size specifies the height/width depending on position. It can be an Int
 | 
			
		||||
      -- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while
 | 
			
		||||
      -- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
 | 
			
		||||
      -- Elements are the elements shown in the layout (in order).
 | 
			
		||||
      -- Layouts are opened in order so that earlier layouts take priority in window sizing.
 | 
			
		||||
      layouts = {
 | 
			
		||||
        {
 | 
			
		||||
          elements = {
 | 
			
		||||
            -- Elements can be strings or table with id and size keys.
 | 
			
		||||
            { id = "scopes", size = 0.25 },
 | 
			
		||||
            "breakpoints",
 | 
			
		||||
            "stacks",
 | 
			
		||||
            "watches",
 | 
			
		||||
          },
 | 
			
		||||
          size = 40, -- 40 columns
 | 
			
		||||
          position = "left",
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          elements = {
 | 
			
		||||
            "repl",
 | 
			
		||||
            -- "console",
 | 
			
		||||
          },
 | 
			
		||||
          size = 0.25, -- 25% of total lines
 | 
			
		||||
          position = "bottom",
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    -- require('nvim-dap-virtual-text').setup()
 | 
			
		||||
    require('mason-nvim-dap').setup {
 | 
			
		||||
| 
						 | 
				
			
			@ -121,6 +149,9 @@ return {
 | 
			
		|||
 | 
			
		||||
    -- toggle to see last session result. Without this ,you can't see session output in case of unhandled exception.
 | 
			
		||||
    vim.keymap.set("n", "<leader>tt", dapui.toggle)
 | 
			
		||||
    vim.keymap.set('n', '<leader>tr', function()
 | 
			
		||||
      dapui.open({ reset = true })
 | 
			
		||||
    end, { desc = 'dap reset ui' })
 | 
			
		||||
    dap.listeners.after.event_initialized['dapui_config'] = dapui.open
 | 
			
		||||
    -- dap.listeners.before.event_terminated['dapui_config'] = dapui.close
 | 
			
		||||
    -- dap.listeners.before.event_exited['dapui_config'] = dapui.close
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,10 +9,11 @@ return {
 | 
			
		|||
		"nvim-treesitter/nvim-treesitter",
 | 
			
		||||
	},
 | 
			
		||||
	config = function()
 | 
			
		||||
		-- local gofmt = require("go.format")
 | 
			
		||||
		require("go").setup()
 | 
			
		||||
 | 
			
		||||
		-- vim.keymap.set('n', 'gF', gofmt.goimport, { desc = 'Go Import' })
 | 
			
		||||
		local gofmt = require("go.format")
 | 
			
		||||
 | 
			
		||||
		vim.keymap.set('n', 'gF', gofmt.goimport, { desc = 'Go Import' })
 | 
			
		||||
	end,
 | 
			
		||||
	event = { "CmdlineEnter" },
 | 
			
		||||
	ft = { "go", 'gomod' },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,8 +7,8 @@ return {
 | 
			
		|||
 | 
			
		||||
		null_ls.setup {
 | 
			
		||||
			sources = {
 | 
			
		||||
				null_ls.builtins.formatting.goimports_reviser,
 | 
			
		||||
				-- null_ls.builtins.formatting.gofumpt,
 | 
			
		||||
				-- null_ls.builtins.formatting.goimports_reviser,
 | 
			
		||||
				null_ls.builtins.formatting.gofumpt,
 | 
			
		||||
				-- null_ls.builtins.formatting.golines,
 | 
			
		||||
			},
 | 
			
		||||
			on_attach = function(client, bufnr)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue