Overseer, conform, splitkeep, formatting, smoothscroll

- Add overseer.nvim
- Add conform.nvim
- Set splitkeep, remove stabilize.nvim
- Set smoothscroll when nightly is available
- Set exrc
- Make formatting more consistent
This commit is contained in:
Amanda Graven 2023-11-30 15:43:20 +01:00
parent bca7124e96
commit 882edc9709

109
init.lua
View file

@ -35,6 +35,7 @@ o.scrolloff = 5 -- Margin between cursor and screen top/bottom
o.showmatch = true -- Highlight matching brackets o.showmatch = true -- Highlight matching brackets
o.splitright = true -- Open new windows below o.splitright = true -- Open new windows below
o.splitbelow = true -- Open new windows to the right o.splitbelow = true -- Open new windows to the right
o.splitkeep = 'screen' -- Keep window position when creating splits
o.title = true -- Set title of terminal window o.title = true -- Set title of terminal window
o.updatetime = 300 -- Write swap file every 300 ms (supposedly reduces delays) o.updatetime = 300 -- Write swap file every 300 ms (supposedly reduces delays)
o.foldlevel = 99 -- Keep all folds open o.foldlevel = 99 -- Keep all folds open
@ -54,6 +55,10 @@ opt.fillchars = { -- Characters to fill certain types of empty space
foldclose='' foldclose=''
} }
opt.diffopt:append({'indent-heuristic', 'algorithm:histogram'}) opt.diffopt:append({'indent-heuristic', 'algorithm:histogram'})
if fn.has('nvim-0.10') then
o.smoothscroll = true -- Scroll by screen lines instead of physical lines
opt.display:append('lastline')
end
o.tabstop = 4 -- A physical tab is 4 characters wide o.tabstop = 4 -- A physical tab is 4 characters wide
o.shiftwidth = 4 -- A unit of indentention is 4 levels wide o.shiftwidth = 4 -- A unit of indentention is 4 levels wide
@ -62,8 +67,11 @@ o.textwidth = 0 -- Comments lines should wrap at 100 chars
o.laststatus = 3 -- Use one global status bar o.laststatus = 3 -- Use one global status bar
-- Set <Leader> key -- Set <Leader> key
g.mapleader = ' ' g.mapleader = ' '
g.maplocalleader = '\\'
vim.cmd 'filetype plugin indent on' vim.cmd 'filetype plugin indent on'
o.exrc = true -- Load .nvim.lua .nvimrc and .exrc files
-- Enable persistent undo -- Enable persistent undo
if fn.has('persistent_undo') then if fn.has('persistent_undo') then
o.undodir = fn.stdpath('data') .. '/undo' o.undodir = fn.stdpath('data') .. '/undo'
@ -137,7 +145,7 @@ do
['ZD'] = {'<Cmd>bdelete<CR>', 'Delete buffer'}, ['ZD'] = {'<Cmd>bdelete<CR>', 'Delete buffer'},
} }
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{}
@ -251,7 +259,7 @@ require'packer'.startup(function(use)
style = 'night' style = 'night'
} }
end} end}
use {'catppuccin/nvim', as = 'catppuccin', config = function () use {'catppuccin/nvim', as = 'catppuccin', config = function()
vim.g.catppuccin_flavour = 'latte' vim.g.catppuccin_flavour = 'latte'
require'catppuccin'.setup { require'catppuccin'.setup {
integrations = { integrations = {
@ -282,6 +290,16 @@ require'packer'.startup(function(use)
-- Editing -- -- Editing --
use 'LunarWatcher/auto-pairs' use 'LunarWatcher/auto-pairs'
use 'ojroques/nvim-bufdel' use 'ojroques/nvim-bufdel'
use {'stevearc/conform.nvim', config = function()
require'conform'.setup {}
vim.api.nvim_create_user_command(
'Conform',
function()
require'conform'.format()
end,
{}
)
end}
--use 'yuttie/comfortable-motion.vim' --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'
@ -350,7 +368,7 @@ 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 'romgrk/barbar.nvim' use {'taketwo/barbar.nvim', branch = 'schedule-wrap'}
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 = false },
@ -418,7 +436,7 @@ require'packer'.startup(function(use)
pathMkfifo = 'mkfifo', pathMkfifo = 'mkfifo',
pathPkill = 'pkill', pathPkill = 'pkill',
env = {}, env = {},
args = function () args = function()
return vim.fn.split(vim.fn.input('Arguments: ', '', 'file')) return vim.fn.split(vim.fn.input('Arguments: ', '', 'file'))
end, end,
}, },
@ -491,13 +509,13 @@ require'packer'.startup(function(use)
use {'rcarriga/nvim-dap-ui', config = function() use {'rcarriga/nvim-dap-ui', config = function()
local dapui, dap = require'dapui', require'dap' local dapui, dap = require'dapui', require'dap'
dapui.setup() dapui.setup()
dap.listeners.after.event_initialized.dapui_config = function () dap.listeners.after.event_initialized.dapui_config = function()
dapui.open {} dapui.open {}
end end
dap.listeners.before.event_terminated.dapui_config = function () dap.listeners.before.event_terminated.dapui_config = function()
dapui.close {} dapui.close {}
end end
dap.listeners.before.event_exited.dapui_config = function () dap.listeners.before.event_exited.dapui_config = function()
dapui.close {} dapui.close {}
end end
require'which-key'.register { require'which-key'.register {
@ -530,7 +548,7 @@ require'packer'.startup(function(use)
}, },
} }
end} end}
use {'j-hui/fidget.nvim', branch = 'legacy'} use {'j-hui/fidget.nvim', config = function() require'fidget'.setup() end}
use 'tpope/vim-fugitive' use 'tpope/vim-fugitive'
use 'tpope/vim-rhubarb' use 'tpope/vim-rhubarb'
use 'shumphrey/fugitive-gitlab.vim' use 'shumphrey/fugitive-gitlab.vim'
@ -557,7 +575,7 @@ require'packer'.startup(function(use)
-- figure out how to ensure java-test and java-debug-adapter -- figure out how to ensure java-test and java-debug-adapter
} }
end} end}
use {'NeogitOrg/neogit', config = function () use {'NeogitOrg/neogit', config = function()
require'neogit'.setup { require'neogit'.setup {
disable_context_highlighting = true, disable_context_highlighting = true,
integrations = { integrations = {
@ -576,8 +594,11 @@ require'packer'.startup(function(use)
vim.notify = require'notify' vim.notify = require'notify'
require'telescope'.load_extension('notify') require'telescope'.load_extension('notify')
end} end}
use {'luukvbaal/stabilize.nvim', config = function() use {'stevearc/overseer.nvim', after = 'nvim-dap', config = function()
require'stabilize'.setup() require'overseer'.setup()
vim.keymap.set('n', '<Leader>rr', '<Cmd>OverseerToggle right<CR>', { desc = "Open" })
vim.keymap.set('n', '<Leader>rn', '<Cmd>OverseerRun<CR>', { desc = "New task" })
vim.keymap.set('n', '<Leader>rc', '<Cmd>OverseerRunCmd<CR>', { desc = "Run shell command" })
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()
@ -624,15 +645,19 @@ require'packer'.startup(function(use)
["<Space>"] = {'<Cmd>Telescope<CR>', 'List pickers'}, ["<Space>"] = {'<Cmd>Telescope<CR>', 'List pickers'},
f = {'<Cmd>Telescope find_files<CR>', 'Files'}, f = {'<Cmd>Telescope find_files<CR>', 'Files'},
F = {'<Cmd>Telescope file_browser<CR>', 'File browser'}, F = {'<Cmd>Telescope file_browser<CR>', 'File browser'},
['<C-f>'] = {function () ['<C-f>'] = {
vim.ui.input({ completion = 'dir' }, function (input) function()
telescope.builtin.find_files { search_dirs = {input} } vim.ui.input(
{ completion = 'dir' },
function(input) telescope.builtin.find_files { search_dirs = {input} }
end) end)
end, 'Files in subdirectory'}, end,
'Files in subdirectory'
},
d = {'<Cmd>Telescope find_files find_command=fd,--type,d,-I<CR>', 'Directories'}, d = {'<Cmd>Telescope find_files find_command=fd,--type,d,-I<CR>', 'Directories'},
r = {'<Cmd>Telescope oldfiles<CR>', 'Recent files'}, r = {'<Cmd>Telescope oldfiles<CR>', 'Recent files'},
g = {'<Cmd>Telescope live_grep<CR>', 'Grep'}, g = {'<Cmd>Telescope live_grep<CR>', 'Grep'},
G = {function () G = {function()
vim.ui.input({ completion = 'dir' }, function(input) vim.ui.input({ completion = 'dir' }, function(input)
telescope.builtin.live_grep { search_dirs = {input} } telescope.builtin.live_grep { search_dirs = {input} }
end) end)
@ -654,13 +679,13 @@ require'packer'.startup(function(use)
use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make', after = 'telescope.nvim', config = function() use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make', after = 'telescope.nvim', config = function()
require'telescope'.load_extension('fzf') require'telescope'.load_extension('fzf')
end} end}
use {'nvim-telescope/telescope-file-browser.nvim', after = 'telescope.nvim', config = function () use {'nvim-telescope/telescope-file-browser.nvim', after = 'telescope.nvim', config = function()
require'telescope'.load_extension('file_browser') require'telescope'.load_extension('file_browser')
end} end}
use {'nvim-telescope/telescope-project.nvim', after = 'telescope.nvim', config = function () use {'nvim-telescope/telescope-project.nvim', after = 'telescope.nvim', config = function()
require'telescope'.load_extension('project') require'telescope'.load_extension('project')
end} end}
use {'nvim-telescope/telescope-ui-select.nvim', after = 'telescope.nvim', config = function () use {'nvim-telescope/telescope-ui-select.nvim', after = 'telescope.nvim', config = function()
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()
@ -689,7 +714,7 @@ require'packer'.startup(function(use)
use 'antoinemadec/FixCursorHold.nvim' use 'antoinemadec/FixCursorHold.nvim'
end end
use 'lewis6991/impatient.nvim' -- speeds up load times 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,
verbose = true, verbose = true,
@ -771,7 +796,7 @@ vim.keymap.set('n', '<Leader>G', '<Cmd>tab Git<CR>', {desc = 'Git status (new ta
---- gitsigns ---- ---- gitsigns ----
require'gitsigns'.setup { require'gitsigns'.setup {
on_attach = function () on_attach = function()
local gitsigns = require'gitsigns' local gitsigns = require'gitsigns'
vim.keymap.set('n', ']c', gitsigns.next_hunk, {desc = 'Next hunk'}) vim.keymap.set('n', ']c', gitsigns.next_hunk, {desc = 'Next hunk'})
vim.keymap.set('n', '[c', gitsigns.prev_hunk, {desc = 'Previous hunk'}) vim.keymap.set('n', '[c', gitsigns.prev_hunk, {desc = 'Previous hunk'})
@ -782,7 +807,7 @@ require'gitsigns'.setup {
vim.ui.input({ vim.ui.input({
prompt = 'Revision to compare to', prompt = 'Revision to compare to',
completion = "customlist,v:lua.require'gitsigns.cli'.complete", completion = "customlist,v:lua.require'gitsigns.cli'.complete",
}, function (revision) }, function(revision)
if not revision then return end if not revision then return end
gitsigns.change_base(revision, true) gitsigns.change_base(revision, true)
end) end)
@ -835,7 +860,7 @@ end
local cmp = require'cmp' local cmp = require'cmp'
local cmp_dap = require'cmp_dap' local cmp_dap = require'cmp_dap'
cmp.setup { cmp.setup {
enabled = function () enabled = function()
return vim.bo.buftype ~= 'prompt' or cmp_dap.is_dap_buffer() return vim.bo.buftype ~= 'prompt' or cmp_dap.is_dap_buffer()
end, end,
preselect = cmp.PreselectMode.None, preselect = cmp.PreselectMode.None,
@ -929,9 +954,10 @@ capabilities.textDocument.foldingRange = {
---- lsp: language servers ---- ---- lsp: language servers ----
au('LspAttach', { au('LspAttach', {
callback = function (event) callback = function(event)
local bufnr = event.buf local bufnr = event.buf
local client = vim.lsp.get_client_by_id(event.data.client_id) local client = vim.lsp.get_client_by_id(event.data.client_id)
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 then
@ -947,7 +973,7 @@ au('LspAttach', {
i = {'<Cmd>Telescope lsp_implementations<CR>', 'Implementation'}, i = {'<Cmd>Telescope lsp_implementations<CR>', 'Implementation'},
a = {code_action, 'Code action'}, a = {code_action, 'Code action'},
r = {vim.lsp.buf.rename, 'Rename'}, r = {vim.lsp.buf.rename, 'Rename'},
h = {function() vim.lsp.inlay_hint(0, nil) end, 'Inlay hints'}, h = {function() vim.lsp.inlay_hint.enable(0, not vim.lsp.inlay_hint.is_enabled()) end, 'Inlay hints'},
l = {vim.lsp.codelens.refresh, 'Show codelenses'}, l = {vim.lsp.codelens.refresh, 'Show codelenses'},
L = {vim.lsp.codelens.run, 'Run codelens'}, L = {vim.lsp.codelens.run, 'Run codelens'},
t = {'<Cmd>Telescope lsp_type_definitions<CR>', 'Type definition'}, t = {'<Cmd>Telescope lsp_type_definitions<CR>', 'Type definition'},
@ -983,9 +1009,14 @@ au('LspAttach', {
}, {buffer = bufnr, mode = 'i'}) }, {buffer = bufnr, mode = 'i'})
vim.bo.tagfunc = 'v:lua.vim.lsp.tagfunc' vim.bo.tagfunc = 'v:lua.vim.lsp.tagfunc'
if pcall(require, 'conform') == true then
vim.bo.formatexpr = "v:lua.require'conform'.formatexpr()"
end
if client.server_capabilities.documentSymbolProvider then
require'nvim-navic'.attach(client, bufnr) require'nvim-navic'.attach(client, bufnr)
end end
end
}) })
-- Enable language servers -- Enable language servers
@ -1018,7 +1049,7 @@ require'lspconfig'.bashls.setup(default)
require'lspconfig'.clangd.setup(default) require'lspconfig'.clangd.setup(default)
au('FileType', { au('FileType', {
pattern = 'java', pattern = 'java',
callback = function () callback = function()
local ok, jdtls = pcall(require, 'jdtls') local ok, jdtls = pcall(require, 'jdtls')
if not ok then return end if not ok then return end
jdtls.tests = require'jdtls.tests' jdtls.tests = require'jdtls.tests'
@ -1048,7 +1079,7 @@ au('FileType', {
init_options = { init_options = {
-- JDTLS plugins -- JDTLS plugins
bundles = (function () bundles = (function()
-- add java-debug-adapter -- add java-debug-adapter
local bundles = { local bundles = {
vim.fn.glob(mason_path'java-debug-adapter' .. '/extension/server/com.microsoft.java.debug.plugin-*.jar', true) vim.fn.glob(mason_path'java-debug-adapter' .. '/extension/server/com.microsoft.java.debug.plugin-*.jar', true)
@ -1065,7 +1096,7 @@ au('FileType', {
capabilities = capabilities, capabilities = capabilities,
on_attach = function (client, bufnr) on_attach = function(client, bufnr)
jdtls.setup_dap() jdtls.setup_dap()
end, end,
} }
@ -1078,10 +1109,10 @@ require'lspconfig'.pyright.setup(default)
-- Defer setup to silence deprecation notice -- Defer setup to silence deprecation notice
au('FileType', { au('FileType', {
pattern = 'sql', pattern = 'sql',
callback = function () callback = function()
require'lspconfig'.sqls.setup { require'lspconfig'.sqls.setup {
capabilities = capabilities, capabilities = capabilities,
on_attach = function (client, bufnr) on_attach = function(client, bufnr)
local ok, sqls = pcall(require, 'sqls') local ok, sqls = pcall(require, 'sqls')
if not ok then return end if not ok then return end
sqls.on_attach(client, bufnr) sqls.on_attach(client, bufnr)
@ -1140,24 +1171,16 @@ require'rust-tools'.setup {
loadOutDirsFromCheck = true, loadOutDirsFromCheck = true,
}, },
checkOnSave = true, checkOnSave = true,
-- Use cargo lints for error checking if available, otherwise fall back to regular clippy -- Error checking settings
check = (function() check = {
if vim.fn.executable('cargo-lints') then
return {
overrideCommand = {"cargo", "lints", "clippy", "--workspace", "--message-format=json", "--all-targets"}
}
else
return {
-- Use clippy for error checking -- Use clippy for error checking
command = "clippy", command = "clippy",
-- Also run checks for tests -- Also run checks for tests
allTargets = true, allTargets = true,
} },
end
end)(),
diagnostics = { diagnostics = {
-- Disable diagnostics with false positives -- Disable diagnostics with false positives
disabled = {'unresolved-import'}; disabled = {'unresolved-import'},
}, },
procMacro = { procMacro = {
-- Enable proc macro support -- Enable proc macro support
@ -1178,7 +1201,7 @@ g.startify_change_to_vcs_root = 1 -- Change working dir to version control roo
g.startify_fortune_use_unicode = 1 -- Enable unicode box drawing in fortune message g.startify_fortune_use_unicode = 1 -- Enable unicode box drawing in fortune message
-- Items to show on the startup screen -- Items to show on the startup screen
g.startify_lists = { g.startify_lists = {
{ type = 'dir', header = {' Recently used '.. fn.getcwd()} }, { type = 'dir', header = {' Recently used ' .. fn.getcwd()} },
{ type = 'files', header = {' Recently used'} }, { type = 'files', header = {' Recently used'} },
{ type = 'sessions', header = {' Sessions'} }, { type = 'sessions', header = {' Sessions'} },
{ type = 'bookmarks', header = {' Bookmarks'} }, { type = 'bookmarks', header = {' Bookmarks'} },