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

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'
@ -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 },
@ -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'
@ -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,11 +645,15 @@ 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'},
@ -932,6 +957,7 @@ 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
@ -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