Formatting, remove outdated plugins, add dadbod-ui

main
Amanda Graven 2024-01-05 09:06:34 +01:00
parent 882edc9709
commit 36f68c6ab1
1 changed files with 104 additions and 57 deletions

161
init.lua
View File

@ -1,8 +1,5 @@
-- Do fast startup if we can -- Enable experimental faster module loader
do vim.loader.enable()
local ok, _ = pcall(require, 'impatient')
if not ok then vim.notify('impatient unavailable') end
end
---- Built in settings ---- ---- Built in settings ----
-- Create a convenient aliases -- Create a convenient aliases
@ -15,12 +12,13 @@ local opt = vim.opt
local workman = false local workman = false
-- Set font -- Set font
o.guifont = 'Iosevka Term Slab,Iosevka:h10' o.guifont = 'IosevkaTermSlab Nerd Font,IosevkaTerm Nerd Font,Iosevka Term Slab,Iosevka:h10:#e-subpixelantialias'
vim.g.neovide_floating_z_height = 1
if fn.hostname() == 'tappy' then if fn.hostname() == 'tappy' then
g.neovide_refresh_rate = 144 g.neovide_refresh_rate = 144
end end
opt.guicursor:append('a:blinkon1000') -- Blink cursor once a second for all modes opt.guicursor:append('a:blinkon1000-blinkoff1000-blinkwait1000') -- Blink cursor once a second for all modes
o.mouse = 'a' -- Enable mouse input o.mouse = 'a' -- Enable mouse input
o.termguicolors = true -- Enable 24bit terminal colors o.termguicolors = true -- Enable 24bit terminal colors
g.neovide_confirm_quit = 1 -- Confirm closing neovide window when changes are unsaved g.neovide_confirm_quit = 1 -- Confirm closing neovide window when changes are unsaved
@ -30,6 +28,9 @@ o.clipboard = 'unnamedplus' -- Use system clipboard by default
o.hidden = true -- Allow buffers to not be attached to a window o.hidden = true -- Allow buffers to not be attached to a window
o.linebreak = true -- Enable word-wrapping at the end of visual lines o.linebreak = true -- Enable word-wrapping at the end of visual lines
o.breakindent = true -- preserve indentention on lines continuing from a wrap o.breakindent = true -- preserve indentention on lines continuing from a wrap
opt.breakindentopt = {
sbr = true -- Line break character should appear before virtual indentention
}
o.hlsearch = true -- Highlight search results o.hlsearch = true -- Highlight search results
o.scrolloff = 5 -- Margin between cursor and screen top/bottom o.scrolloff = 5 -- Margin between cursor and screen top/bottom
o.showmatch = true -- Highlight matching brackets o.showmatch = true -- Highlight matching brackets
@ -50,9 +51,9 @@ opt.listchars = { -- Symbols for whitespace chars when 'list' is ena
opt.fillchars = { -- Characters to fill certain types of empty space with opt.fillchars = { -- Characters to fill certain types of empty space with
diff = ' ', diff = ' ',
fold = ' ', fold = ' ',
foldopen= '', foldopen = '',
foldsep=' ', foldsep = ' ',
foldclose='' foldclose = ''
} }
opt.diffopt:append({'indent-heuristic', 'algorithm:histogram'}) opt.diffopt:append({'indent-heuristic', 'algorithm:histogram'})
if fn.has('nvim-0.10') then if fn.has('nvim-0.10') then
@ -103,6 +104,9 @@ function _G.zoom(delta)
local properties = { local properties = {
title = 'Font size', title = 'Font size',
hide_from_history = true, hide_from_history = true,
on_close = function()
zoom_notification = nil
end
} }
if zoom_notification ~= nil then if zoom_notification ~= nil then
properties.replace = zoom_notification.id properties.replace = zoom_notification.id
@ -148,7 +152,7 @@ do
which_key.register { ['<C-l>'] = {function() which_key.register { ['<C-l>'] = {function()
local ok, notify = pcall(require, 'notify') local ok, notify = pcall(require, 'notify')
if ok then if ok then
notify.dismiss{} notify.dismiss {}
end end
vim.lsp.buf.clear_references() vim.lsp.buf.clear_references()
vim.cmd('nohlsearch|diffupdate|normal! <C-l>') vim.cmd('nohlsearch|diffupdate|normal! <C-l>')
@ -277,7 +281,6 @@ require'packer'.startup(function(use)
-- Filetype plugins -- -- Filetype plugins --
use 'rhysd/vim-crystal' use 'rhysd/vim-crystal'
use 'editorconfig/editorconfig-vim'
use 'bakpakin/fennel.vim' use 'bakpakin/fennel.vim'
use 'mboughaba/i3config.vim' use 'mboughaba/i3config.vim'
use 'plasticboy/vim-markdown' use 'plasticboy/vim-markdown'
@ -285,23 +288,32 @@ require'packer'.startup(function(use)
use 'lifepillar/pgsql.vim' use 'lifepillar/pgsql.vim'
use 'ajouellette/sway-vim-syntax' use 'ajouellette/sway-vim-syntax'
use 'cespare/vim-toml' use 'cespare/vim-toml'
use 'rust-lang/rust.vim'
-- Editing -- -- Editing --
use 'LunarWatcher/auto-pairs' use 'LunarWatcher/auto-pairs'
use 'ojroques/nvim-bufdel' use 'ojroques/nvim-bufdel'
use {'stevearc/conform.nvim', config = function() use {'stevearc/conform.nvim', config = function()
require'conform'.setup {} require'conform'.setup {
format_on_save = {
lsp_fallback = true,
filter = function(client)
return client.name == 'rust-analyzer'
end
}
}
vim.api.nvim_create_user_command( vim.api.nvim_create_user_command(
'Conform', 'Conform',
function() function()
require'conform'.format() require'conform'.format {
lsp_fallback = true,
}
end, end,
{} {
desc = 'Format buffer',
}
) )
end} end}
--use 'yuttie/comfortable-motion.vim' use {'jbyuki/instant.nvim', config = function()
use {'jbyuki/instant.nvim', config = function ()
vim.g.instant_username = 'agraven' vim.g.instant_username = 'agraven'
end} end}
use {'mizlan/iswap.nvim', config = function() use {'mizlan/iswap.nvim', config = function()
@ -309,7 +321,7 @@ require'packer'.startup(function(use)
require'which-key'.register{['<Leader>s'] = {'<Cmd>ISwapWith<CR>','Swap'}} require'which-key'.register{['<Leader>s'] = {'<Cmd>ISwapWith<CR>','Swap'}}
end} end}
use 'bfredl/nvim-luadev' -- lua scratchpad use 'bfredl/nvim-luadev' -- lua scratchpad
use {'windwp/nvim-projectconfig', config = function () use {'windwp/nvim-projectconfig', config = function()
require'nvim-projectconfig'.setup { require'nvim-projectconfig'.setup {
-- Load project configuration when changing directory -- Load project configuration when changing directory
autocmd = true, autocmd = true,
@ -317,10 +329,8 @@ require'packer'.startup(function(use)
end} end}
use 'tpope/vim-repeat' use 'tpope/vim-repeat'
use 'tpope/vim-sleuth' use 'tpope/vim-sleuth'
-- spellsitter: syntax aware spellchecking
use {'lewis6991/spellsitter.nvim', config = function() require'spellsitter'.setup() end}
use 'tpope/vim-surround' use 'tpope/vim-surround'
use {'vim-test/vim-test', config = function () use {'vim-test/vim-test', config = function()
vim.g['test#neovim#term_position'] = 'vert' vim.g['test#neovim#term_position'] = 'vert'
vim.g['test#strategy'] = 'neovim' vim.g['test#strategy'] = 'neovim'
end} end}
@ -349,7 +359,7 @@ require'packer'.startup(function(use)
use 'mfussenegger/nvim-jdtls' use 'mfussenegger/nvim-jdtls'
use 'simrat39/rust-tools.nvim' use 'simrat39/rust-tools.nvim'
use 'pmizio/typescript-tools.nvim' use 'pmizio/typescript-tools.nvim'
use {'nvimtools/none-ls.nvim', requires = {'nvim-lua/plenary.nvim'}, config = function () use {'nvimtools/none-ls.nvim', requires = {'nvim-lua/plenary.nvim'}, config = function()
local null_ls = require'null-ls' local null_ls = require'null-ls'
null_ls.setup { null_ls.setup {
sources = { sources = {
@ -359,7 +369,7 @@ require'packer'.startup(function(use)
} }
end} end}
use 'SmiteshP/nvim-navic' use 'SmiteshP/nvim-navic'
use {'utilyre/barbecue.nvim', config = function () use {'utilyre/barbecue.nvim', config = function()
require'barbecue'.setup { require'barbecue'.setup {
show_modified = true, show_modified = true,
} }
@ -368,10 +378,14 @@ require'packer'.startup(function(use)
-- UI elements -- -- UI elements --
use 'vim-airline/vim-airline' use 'vim-airline/vim-airline'
use 'vim-airline/vim-airline-themes' use 'vim-airline/vim-airline-themes'
use {'taketwo/barbar.nvim', branch = 'schedule-wrap'} use 'romgrk/barbar.nvim'
use {'luckasRanarison/clear-action.nvim', config = function() use {'luckasRanarison/clear-action.nvim', config = function()
require'clear-action'.setup { require'clear-action'.setup {
signs = { enable = false }, signs = {
enable = true,
combine = true,
show_count = false,
},
popup = { enable = true }, popup = { enable = true },
} }
end} end}
@ -379,9 +393,23 @@ require'packer'.startup(function(use)
vim.g.bookmark_no_default_key_mappings = 1 vim.g.bookmark_no_default_key_mappings = 1
vim.g.bookmark_save_per_working_dir = 1 vim.g.bookmark_save_per_working_dir = 1
end} end}
use {'kristijanhusak/vim-dadbod-ui', requires = {'tpope/vim-dadbod', 'kristijanhusak/vim-dadbod-completion'}, config = function()
vim.g.db_ui_use_nerd_fonts = 1
vim.g.db_ui_auto_execute_table_helpers = 1
vim.g.db_ui_win_position = 'right'
vim.o.previewheight = 40
vim.api.nvim_create_autocmd('FileType', {
group = 'luarc',
pattern = {'sql','mysql','plsql'},
callback = function()
require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} })
end,
desc = 'SQL dadbod completion',
})
end}
use {'mfussenegger/nvim-dap', config = function() use {'mfussenegger/nvim-dap', config = function()
local dap = require'dap' local dap = require'dap'
vim.fn.sign_define('DapBreakpoint', {text='', texthl='DiagnosticError'}) vim.fn.sign_define('DapBreakpoint', {text = '', texthl = 'DiagnosticError'})
dap.adapters.codelldb = { dap.adapters.codelldb = {
type = 'server', type = 'server',
port = '${port}', port = '${port}',
@ -533,7 +561,7 @@ require'packer'.startup(function(use)
enhanced_diff_hl = true, enhanced_diff_hl = true,
} }
end} end}
use {'stevearc/dressing.nvim', config = function() use {'stevearc/dressing.nvim', after = 'telescope.nvim', config = function()
vim.cmd'highlight link FloatTitle TelescopeBorder' vim.cmd'highlight link FloatTitle TelescopeBorder'
require'dressing'.setup { require'dressing'.setup {
input = { input = {
@ -587,7 +615,7 @@ require'packer'.startup(function(use)
}, },
} }
end} end}
use {'rcarriga/nvim-notify', after = 'telescope.nvim', config = function () use {'rcarriga/nvim-notify', after = 'telescope.nvim', config = function()
require'notify'.setup { require'notify'.setup {
stages = 'fade' stages = 'fade'
} }
@ -596,9 +624,18 @@ require'packer'.startup(function(use)
end} end}
use {'stevearc/overseer.nvim', after = 'nvim-dap', config = function() use {'stevearc/overseer.nvim', after = 'nvim-dap', config = function()
require'overseer'.setup() require'overseer'.setup()
vim.keymap.set('n', '<Leader>rr', '<Cmd>OverseerToggle right<CR>', { desc = "Open" }) require'which-key'.register {
vim.keymap.set('n', '<Leader>rn', '<Cmd>OverseerRun<CR>', { desc = "New task" }) ['<Leader>r'] = {
vim.keymap.set('n', '<Leader>rc', '<Cmd>OverseerRunCmd<CR>', { desc = "Run shell command" }) name = 'Overseer (run tasks)',
r = {'<Cmd>OverseerToggle right<CR>', 'Open' },
R = {'<Cmd>OverseerToggle bottom<CR>', 'Open (bottom)' },
n = {'<Cmd>OverseerRun<CR>', 'New task' },
c = {'<Cmd>OverseerRunCmd<CR>', 'Run shell command' },
l = {'<Cmd>OverseerLoadBundle!<CR>', 'Load task list'},
L = {'<Cmd>OverseerLoadBundle<CR>', 'Load and start task list'},
s = {'<Cmd>OverseerSaveBundle<CR>', 'Save task list'}
}
}
end} end}
use 'mhinz/vim-startify' use 'mhinz/vim-startify'
use {'nvim-telescope/telescope.nvim', after = 'which-key.nvim', config = function() use {'nvim-telescope/telescope.nvim', after = 'which-key.nvim', config = function()
@ -649,8 +686,8 @@ require'packer'.startup(function(use)
function() function()
vim.ui.input( vim.ui.input(
{ completion = 'dir' }, { completion = 'dir' },
function(input) telescope.builtin.find_files { search_dirs = {input} } function(input) telescope.builtin.find_files { search_dirs = {input} } end
end) )
end, end,
'Files in subdirectory' 'Files in subdirectory'
}, },
@ -689,7 +726,7 @@ require'packer'.startup(function(use)
require'telescope'.load_extension('ui-select') require'telescope'.load_extension('ui-select')
end} end}
use {'nvim-telescope/telescope-dap.nvim', after = 'telescope.nvim', config = function() use {'nvim-telescope/telescope-dap.nvim', after = 'telescope.nvim', config = function()
require'telescope'.load_extension'dap' require'telescope'.load_extension('dap')
end} end}
use {'debugloop/telescope-undo.nvim', after = 'telescope.nvim', config = function() use {'debugloop/telescope-undo.nvim', after = 'telescope.nvim', config = function()
require'telescope'.load_extension('undo') require'telescope'.load_extension('undo')
@ -703,17 +740,13 @@ require'packer'.startup(function(use)
} }
end} end}
use 'kyazdani42/nvim-tree.lua' use 'kyazdani42/nvim-tree.lua'
use 'simrat39/symbols-outline.nvim' use 'hedyhli/outline.nvim'
use {'folke/which-key.nvim', config = function() require'which-key'.setup() end} use {'folke/which-key.nvim', config = function() require'which-key'.setup() end}
-- Utility and libraries -- Utility and libraries
use 'nvim-lua/plenary.nvim' use 'nvim-lua/plenary.nvim'
use 'ryanoasis/vim-devicons' use 'ryanoasis/vim-devicons'
use 'kyazdani42/nvim-web-devicons' use 'kyazdani42/nvim-web-devicons'
if not vim.fn.has('nvim-0.8') then
use 'antoinemadec/FixCursorHold.nvim'
end
use 'lewis6991/impatient.nvim' -- speeds up load times
use {'ellisonleao/dotenv.nvim', config = function() use {'ellisonleao/dotenv.nvim', config = function()
require'dotenv'.setup { require'dotenv'.setup {
enable_on_load = false, enable_on_load = false,
@ -772,19 +805,29 @@ require'which-key'.register {
['<A-b>'] = {'<Cmd>BufferPick<CR>', 'Pick buffer'}, ['<A-b>'] = {'<Cmd>BufferPick<CR>', 'Pick buffer'},
['<A-p>'] = {'<Cmd>BufferPin<CR>', 'Pin buffer'}, ['<A-p>'] = {'<Cmd>BufferPin<CR>', 'Pin buffer'},
['<A-d>'] = {'<Cmd>BufferClose<CR>', 'Delete buffer'}, ['<A-d>'] = {'<Cmd>BufferClose<CR>', 'Delete buffer'},
['<A-x>'] = {'<Cmd>BufferPickDelete<CR>', 'Delete picked buffer'},
['<A-<>'] = {'<Cmd>BufferMovePrevious<CR>', 'Move buffer left'}, ['<A-<>'] = {'<Cmd>BufferMovePrevious<CR>', 'Move buffer left'},
['<A->>'] = {'<Cmd>BufferMoveNext<CR>', 'Move buffer right'}, ['<A->>'] = {'<Cmd>BufferMoveNext<CR>', 'Move buffer right'},
} }
require'which-key'.register {
['<Leader>b'] = {
name = 'Buffers',
[','] = { '<Cmd>BufferPrevious<CR>', 'Next buffer'},
['.'] = { '<Cmd>BufferNext<CR>', 'Previous buffer'},
b = {'<Cmd>BufferPick<CR>', 'Pick buffer'},
p = {'<Cmd>BufferPin<CR>', 'Pin buffer'},
d = {'<Cmd>BufferClose<CR>', 'Delete buffer'},
x = {'<Cmd>BufferPickDelete<CR>', 'Delete picked buffer'},
h = {'<Cmd>BufferMovePrevious<CR>', 'Move buffer left'},
l = {'<Cmd>BufferMoveNext<CR>', 'Move buffer right'},
}
}
---- devicons ---- ---- devicons ----
require'nvim-web-devicons'.setup { default = true } require'nvim-web-devicons'.setup { default = true }
---- editorconfig ----
g.EditorConfig_exclude_patterns = {'fugitive://.*'}
---- fidget ---- ---- fidget ----
require'fidget'.setup {} require'fidget'.setup {}
@ -828,6 +871,8 @@ require'gitsigns'.setup {
L = {gitsigns.toggle_current_line_blame, 'Toggle line blame'}, L = {gitsigns.toggle_current_line_blame, 'Toggle line blame'},
b = {':Gitsigns change_base ', 'Change diff base'}, b = {':Gitsigns change_base ', 'Change diff base'},
B = {gitsigns.reset_base, 'Reset diff base'}, B = {gitsigns.reset_base, 'Reset diff base'},
p = {gitsigns.preview_hunk_inline, 'Preview hunk'},
P = {gitsigns.preview_hunk, 'Preview hunk popup'},
} }
} }
end end
@ -903,7 +948,7 @@ cmp.setup {
-- Complete common substring -- Complete common substring
['<C-l>'] = cmp.mapping(cmp.mapping.complete_common_string(), {'i', 'c'}), ['<C-l>'] = cmp.mapping(cmp.mapping.complete_common_string(), {'i', 'c'}),
-- Complete -- Complete
['<C-Space>'] = cmp.mapping(cmp.mapping.complete{}, {'i', 'c'}), ['<C-Space>'] = cmp.mapping(cmp.mapping.complete {}, {'i', 'c'}),
-- Confirm -- Confirm
['<CR>'] = cmp.mapping(cmp.mapping.confirm { select = false }, {'i', 'c'}), ['<CR>'] = cmp.mapping(cmp.mapping.confirm { select = false }, {'i', 'c'}),
}, },
@ -960,7 +1005,7 @@ au('LspAttach', {
if not client then return end if not client then return end
local function code_action() local function code_action()
local ok, clear_action = pcall(require, 'clear-action') local ok, clear_action = pcall(require, 'clear-action')
if ok then if ok and client.name ~= 'jdtls' then
clear_action.code_action() clear_action.code_action()
else else
vim.lsp.buf.code_action() vim.lsp.buf.code_action()
@ -1144,7 +1189,6 @@ g.rustfmt_emit_files = 1
-- Use nigtly rustfmt for unstable settings -- Use nigtly rustfmt for unstable settings
g.rustfmt_command = 'rustup run nightly rustfmt' g.rustfmt_command = 'rustup run nightly rustfmt'
-- use cargo-lints if available
---- rust-tools ---- ---- rust-tools ----
require'rust-tools'.setup { require'rust-tools'.setup {
tools = { tools = {
@ -1186,6 +1230,9 @@ require'rust-tools'.setup {
-- Enable proc macro support -- Enable proc macro support
enable = true, enable = true,
}, },
rustfmt = {
extraArgs = { '+nightly' }
},
}, },
}, },
}, },
@ -1210,17 +1257,15 @@ g.startify_lists = {
---- symbols-outline ---- ---- symbols-outline ----
require'symbols-outline'.setup { require'outline'.setup {
-- Don't display preview automatically outline_window = {
auto_preview = false, -- Use absolute number of columns instead of percentage for sizing
-- Don't highlight the hovered item relative_width = false,
highlight_hovered_item = true, -- Window should be 30 columns wide
-- Width should be in colums, not percent width = 30,
relative_width = false, },
-- width of the symbols window
width = 30,
} }
require'which-key'.register({['<Leader>o'] = {'<Cmd>SymbolsOutline<CR>', 'Symbols outline'}}) require'which-key'.register({['<Leader>o'] = {'<Cmd>Outline<CR>', 'Symbols outline'}})
---- tree ---- ---- tree ----
@ -1246,6 +1291,8 @@ require('nvim-tree').setup {
git = { git = {
-- Don't hide .gitignore'd files by default -- Don't hide .gitignore'd files by default
ignore = false, ignore = false,
-- Extend timeout
timeout = 5000,
}, },
-- Reload the tree when its window is focused -- Reload the tree when its window is focused
reload_on_bufenter = true, reload_on_bufenter = true,