1
0
Fork 0

nvim: winopts & misc

This commit is contained in:
Vladimír Dudr 2023-02-17 19:14:04 +01:00
parent 05b6e90111
commit 80a051bb9b
5 changed files with 78 additions and 62 deletions

View file

@ -16,7 +16,6 @@ function M.setup()
vim.o.ignorecase = true
vim.o.inccommand = 'split'
vim.o.incsearch = true
vim.o.list = false
vim.o.mouse = ''
vim.o.path = '**'
vim.o.ruler = true
@ -35,6 +34,12 @@ function M.setup()
--vim.o.clipboard = "unnamedplus"
vim.o.guifont = 'Hack:12h'
vim.o.listchars = 'tab:❮⋯❯,trail:⸬,nbsp:·'
vim.o.grepprg = 'rg --vimgrep --no-ignore --smart-case $*'
vim.o.grepformat = '%f:%l:%c:%m'
local function set_winopts()
vim.o.cursorline = true
vim.o.foldcolumn = 'auto:1'
@ -43,7 +48,7 @@ function M.setup()
vim.o.number = true
vim.o.signcolumn = 'yes'
vim.o.relativenumber = false
vim.o.list = true
vim.o.list = false
vim.o.statusline = ''
.. ' %{fnamemodify(getcwd(),":t")}' -- basename of cwd
.. '%( │  %{get(b:,"gitsigns_head","")}%)' -- branch
@ -58,55 +63,54 @@ function M.setup()
end
set_winopts()
vim.o.listchars = 'tab:❮⋯❯,trail:⸬,nbsp:·'
vim.o.grepprg = 'rg --vimgrep --no-ignore --smart-case $*'
vim.o.grepformat = '%f:%l:%c:%m'
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter', 'FileType' }, {
pattern = '*',
callback = function(args)
local buf = args.buf
local buftype = vim.bo[buf].buftype
if buftype == 'prompt' then
return -- plugins handle this usually themselves
end
set_winopts()
if buftype == 'nofile' or buftype == 'help' then
vim.o.list = false
vim.bo[buf].buflisted = false
vim.wo.number = false
vim.wo.signcolumn = 'auto'
-- vim.wo.foldcolumn = 0
vim.wo.statuscolumn = ''
vim.keymap.set('n', 'q', '<Cmd>:q<CR>', { buffer = buf })
if vim.bo[buf].filetype ~= 'qf' then
vim.wo.statusline = '%f'
end
end
end,
})
-- vim.api.nvim_create_autocmd('FileType', {
-- pattern = { 'qf', 'man', 'help', 'tsplayground', 'checkhealth', 'OverseerList' },
-- vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter', 'FileType' }, {
-- pattern = '*',
-- callback = function(args)
-- local buf = args.buf
-- local bo = vim.bo[buf]
-- if bo.filetype == 'help' and bo.buftype ~= 'help' then
-- return
-- local buftype = vim.bo[buf].buftype
-- if buftype == 'prompt' then
-- return -- plugins handle this usually themselves
-- end
-- vim.bo[buf].buflisted = false
-- vim.wo.number = false
-- vim.wo.signcolumn = 'auto'
-- vim.keymap.set('n', 'q', '<Cmd>:q<CR>', { buffer = buf })
--
-- if vim.bo[buf].filetype ~= 'qf' then
-- vim.wo.statusline = '%Y %f%=%l:%v %P'
-- set_winopts()
-- if buftype == 'nofile' or buftype == 'help' then
-- vim.o.list = false
-- vim.bo[buf].buflisted = false
-- vim.wo.number = false
-- vim.wo.signcolumn = 'auto'
-- -- vim.wo.foldcolumn = 0
-- vim.wo.statuscolumn = ''
-- vim.keymap.set('n', 'q', '<Cmd>:q<CR>', { buffer = buf })
-- if vim.bo[buf].filetype ~= 'qf' then
-- vim.wo.statusline = '%f'
-- end
-- end
-- end,
-- })
--
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'qf', 'man', 'help', 'tsplayground', 'checkhealth', 'Overseer*' },
callback = function(args)
local buf = args.buf
local bo = vim.bo[buf]
if bo.filetype == 'help' and bo.buftype ~= 'help' then
return
end
vim.bo[buf].buflisted = false
vim.opt_local.number = false
vim.opt_local.signcolumn = 'no'
vim.keymap.set('n', 'q', '<Cmd>:q<CR>', { buffer = buf })
if vim.bo[buf].filetype ~= 'qf' then
vim.opt_local.statusline = '%Y | %f%=%l:%v %P'
end
if vim.fn.has('nvim-0.9') then
vim.o.statuscolumn = ''
end
end,
})
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, {
pattern = { 'Trouble' },

View file

@ -70,6 +70,9 @@ function M.config()
link('@type.qualifier', 'Keyword')
link('@storageclass', 'Keyword')
link('@modifier', 'Keyword')
link('@attribute', 'PreProc')
link('@tag.attribute', 'Identifier')
link('@tag.delimiter', 'Delimiter')
@ -163,8 +166,6 @@ function M.config()
gr:hl('DiagnosticVirtualTextHint', 'hint', nil, { 'italic', })
gr:hl('DiagnosticVirtualTextOk', 'ok', nil, { 'italic', })
gr:hl('@attribute', 'aqua')
-- gr:hl('GitSignsAddLine', nil, 'faded_green', {})
-- vim.fn.sign_define('GitSignsAdd', { text = '│', texthl = 'GitSignsAdd', linehl = 'GitSignsAddLine', culhl='CursorLine' })
end,

View file

@ -33,12 +33,15 @@ return {
map('n', '<leader>gR', gs.reset_buffer, { desc = 'Gitsigns reset buffer' })
map('n', '<leader>gp', gs.preview_hunk, { desc = 'Gitsigns preview hunk' })
map('n', '<leader>gb', function() gs.blame_line { full = true } end, { desc = 'Gitsigns blame line' })
map('n', '<leader>gB', gs.toggle_current_line_blame, { desc = 'Gitsigns toggle blame line' })
map('n', '<leader>gtb', gs.toggle_current_line_blame, { desc = 'Gitsigns toggle blame line' })
map('n', '<leader>gtd', gs.toggle_deleted, { desc = 'Gitsigns toggle deleted' })
map('n', '<leader>gd', gs.diffthis, { desc = 'Gitsigns diff this' })
map('n', '<leader>gD', function() gs.diffthis('~') end, { desc = 'Gitsigns diff this ~' })
map('n', '<leader>gd', gs.toggle_deleted, { desc = 'Gitsigns toggle deleted' })
map('n', '<leader>ggD', function() vim.ui.input({prompt = 'Branch?'}, function (input)
gs.diffthis(input) end) end, { desc = 'Gitsigns diff this' })
map('n', '<leader>gDD', function() gs.diffthis('~') end, { desc = 'Gitsigns diff this ~' })
map('n', '<leader>gD', function()
vim.ui.input({ prompt = 'Branch?' }, function(input)
gs.diffthis(input)
end)
end, { desc = 'Gitsigns diff this' })
-- Text object
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'Inner git hunk' })

View file

@ -11,14 +11,14 @@ local function formatting_filter(c)
end
local function navic_attach(client, bufnr)
require('nvim-navic').attach(client, bufnr)
vim.wo.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}"
vim.api.nvim_create_autocmd('LspDetach', {
require('nvim-navic').attach(client, bufnr)
vim.wo.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}"
vim.api.nvim_create_autocmd('LspDetach', {
pattern = vim.api.nvim_buf_get_name(bufnr),
once = true,
callback = function ()
callback = function()
vim.cmd.setlocal('winbar<')
end
end,
})
end
@ -177,6 +177,13 @@ local function config()
omnisharp = { -- {{{
handlers = {
['textDocument/definition'] = require('omnisharp_extended').handler,
-- ['textDocument/publishDiagnostics'] = vim.lsp.with(
-- vim.lsp.diagnostic.on_publish_diagnostics, {
-- virtual_text = {
-- severity = { vim.diagnostic.severity.WARN, vim.diagnostic.severity.ERROR },
-- },
-- }
-- ),
},
cmd = { '/usr/bin/omnisharp' },
enable_editorconfig_support = true,
@ -212,12 +219,12 @@ local function config()
root_dir = function(startpath)
local u = require('lspconfig.util')
return u.search_ancestors(startpath, function(path)
return not string.find(path, '/vendor/') and (
u.path.exists(u.path.join(path, 'composer.json'))
or u.path.exists(u.path.join(path, 'sharedLibs'))
or u.path.exists(u.path.join(path, '.git'))
)
end)
return not string.find(path, '/vendor/') and (
u.path.exists(u.path.join(path, 'composer.json'))
or u.path.exists(u.path.join(path, 'sharedLibs'))
or u.path.exists(u.path.join(path, '.git'))
)
end)
end,
}, -- }}}
yamlls = { -- {{{

View file

@ -1,6 +1,7 @@
return {
{ 'norcalli/nvim-colorizer.lua',
config = true,
keys = { { '<leader>oc', '<Cmd>ColorizerToggle<Cr>' } },
cmd = 'ColorizerToggle',
},