nvim: Update formatting

This commit is contained in:
Marty Oehme 2022-11-01 15:56:23 +01:00
parent ba5d5d2561
commit 7fbdbf0203
Signed by: Marty
GPG key ID: 73BA40D5AFAF49C9
6 changed files with 78 additions and 37 deletions

View file

@ -11,15 +11,18 @@ require('maps')
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
command = 'silent! lua require"vim.highlight".on_yank{timeout=500}',
desc = "Highlight yanked text whenevery yanking something",
group = vim.api.nvim_create_augroup('highlightyanks', { clear = true }),
group = vim.api.nvim_create_augroup('highlightyanks', { clear = true })
})
-- Special setting for editing gopass files - make sure nothing leaks outside the directories it is supposed to
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
pattern = { "/dev/shm/gopass.*", "/dev/shm/pass.?*/?*.txt", "$TMPDIR/pass.?*/?*.txt", "/tmp/pass.?*/?*.txt" },
pattern = {
"/dev/shm/gopass.*", "/dev/shm/pass.?*/?*.txt",
"$TMPDIR/pass.?*/?*.txt", "/tmp/pass.?*/?*.txt"
},
command = 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=',
desc = "Don't leak any information when editing potential password files",
group = vim.api.nvim_create_augroup('passnoleak', { clear = true }),
group = vim.api.nvim_create_augroup('passnoleak', { clear = true })
})
api.nvim_exec('runtime abbrev.vim', false)
@ -31,5 +34,5 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, {
vim.defer_fn(function() vim.loop.kill(pid, WINCH) end, 20)
end,
desc = "Fix neovim sizing issues if opening same time as alacritty",
group = vim.api.nvim_create_augroup('alacritty_fixsize', { clear = true }),
group = vim.api.nvim_create_augroup('alacritty_fixsize', { clear = true })
})

View file

@ -1,4 +1,4 @@
require('nvim-autopairs').setup({check_ts = true})
require('nvim-autopairs').setup({ check_ts = true })
--- Auto-space rules
local npairs = require 'nvim-autopairs'
@ -7,12 +7,10 @@ local Rule = require 'nvim-autopairs.rule'
npairs.add_rules {
Rule(' ', ' '):with_pair(function(opts)
local pair = opts.line:sub(opts.col, opts.col + 1)
return vim.tbl_contains({'()', '[]', '{}'}, pair)
return vim.tbl_contains({ '()', '[]', '{}' }, pair)
end)
}
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on('confirm_done',
cmp_autopairs.on_confirm_done({map_char = {tex = ''}}))
-- add a lisp filetype (wrap my-function), FYI: Hardcoded = { "clojure", "clojurescript", "fennel", "janet" }
cmp_autopairs.lisp[#cmp_autopairs.lisp + 1] = "racket"
cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))

View file

@ -4,29 +4,29 @@ local lspkind = require 'lspkind'
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col,
col)
:match("%s") == nil
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col,
col)
:match("%s") == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true),
mode, true)
mode, true)
end
vim.o.completeopt = "menu,menuone,noselect"
-- completion items
require('cmp').register_source('vCard', require('completion_vcard').setup_cmp(
'~/documents/contacts/myconts'))
'~/documents/contacts/myconts'))
vim.g.vsnip_snippet_dir = (vim.env.XDG_DATA_HOME or "~/.local/share") ..
"/nvim/snippets"
"/nvim/snippets"
cmp.setup({
snippet = {expand = function(args) vim.fn["vsnip#anonymous"](args.body) end},
snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end },
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), {'i', 'c'}),
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
@ -34,7 +34,7 @@ cmp.setup({
}),
-- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items.
['<CR>'] = cmp.mapping.confirm({select = false}),
['<CR>'] = cmp.mapping.confirm({ select = false }),
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
@ -45,7 +45,7 @@ cmp.setup({
else
fallback()
end
end, {"i", "s"}),
end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function()
if cmp.visible() then
@ -53,7 +53,7 @@ cmp.setup({
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, {"i", "s"})
end, { "i", "s" })
},
formatting = {
format = lspkind.cmp_format({
@ -80,18 +80,18 @@ require 'cmp_pandoc'.setup{
}
if vim.o.ft == 'clap_input' and vim.o.ft == 'guihua' and vim.o.ft ==
'guihua_rust' then require'cmp'.setup.buffer {completion = {enable = false}} end
'guihua_rust' then require 'cmp'.setup.buffer { completion = { enable = false } } end
-- Use buffer source for `/` search
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({{name = 'buffer'}})
sources = cmp.config.sources({ { name = 'buffer' } })
})
-- Use cmdline & path source for ':' in vim
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({{name = 'path'}}, {{name = 'cmdline'}})
sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } })
})
require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol

View file

@ -0,0 +1,40 @@
-- require('gitsigns').setup {
-- on_attach = function(bufnr)
-- local gs = package.loaded.gitsigns
--
-- local function map(mode, l, r, opts)
-- opts = opts or {}
-- opts.buffer = bufnr
-- vim.keymap.set(mode, l, r, opts)
-- end
--
-- -- Navigation
-- map('n', ']h', function()
-- if vim.wo.diff then return ']h' end
-- vim.schedule(function() gs.next_hunk() end)
-- return '<Ignore>'
-- end, {expr = true})
--
-- map('n', '[h', function()
-- if vim.wo.diff then return '[h' end
-- vim.schedule(function() gs.prev_hunk() end)
-- return '<Ignore>'
-- end, {expr = true})
--
-- -- Actions
-- map({'n', 'v'}, '<leader>hs', ':Gitsigns stage_hunk<CR>')
-- map('n', '<leader>hS', gs.stage_buffer)
-- map({'n', 'v'}, '<leader>hr', ':Gitsigns reset_hunk<CR>')
-- map('n', '<leader>hR', gs.reset_buffer)
-- map('n', '<leader>hu', gs.undo_stage_hunk)
-- map('n', '<leader>hp', gs.preview_hunk)
-- map('n', '<leader>hb', function() gs.blame_line {full = true} end)
-- map('n', '<leader>hB', gs.toggle_current_line_blame)
-- map('n', '<leader>hd', gs.diffthis)
-- map('n', '<leader>hD', function() gs.diffthis('~') end)
-- map('n', '<leader>hdd', gs.toggle_deleted)
--
-- -- Text object
-- map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
-- end
-- }

View file

@ -2,15 +2,15 @@ local install_path = vim.fn.stdpath("data") .. "/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " ..
install_path)
install_path)
end
-- Compile on plugin edits
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
vim.api.nvim_create_autocmd({"BufWritePost"}, {
pattern = "plugins.lua",
command = "PackerCompile",
desc = "Compile plugins after editing plugin list",
group = vim.api.nvim_create_augroup('compilepackages', { clear = true })
group = vim.api.nvim_create_augroup('compilepackages', {clear = true})
})
local use = require("packer").use
@ -34,11 +34,7 @@ require("packer").startup(function()
'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter
requires = {'nvim-lua/plenary.nvim'},
tag = 'release',
config = function()
require('gitsigns').setup {
keymaps = {['n ]c'] = nil, ['n [c'] = nil}
}
end,
config = function() require('plug._gitsigns') end,
event = "BufRead"
}
use {
@ -213,11 +209,15 @@ require("packer").startup(function()
-- lsp
use 'neovim/nvim-lspconfig' -- some commong language server configurations
use 'simrat39/symbols-outline.nvim' -- vista-like outline view for code
use {
'simrat39/symbols-outline.nvim',
config = function() require('symbols-outline').setup() end
} -- vista-like outline view for code
use 'ray-x/lsp_signature.nvim'
use {
'ray-x/navigator.lua',
requires = {'ray-x/guihua.lua', run = 'cd lua/fzy && make'}
requires = {'ray-x/guihua.lua', run = 'cd lua/fzy && make'},
config = function() require('plug._lsp') end
}
-- and completion
use {

View file

@ -1,8 +1,8 @@
" PLUGIN: vim-pandoc
" handle markdown files with pandoc (and pandoc syntax!)
let g:pandoc#modules#disabled = [ "keyboard", "folding" ]
let g:pandoc#filetypes#pandoc_markdown = 1
let g:pandoc#filetypes#handled = [ "extra", "latex", "markdown", "pandoc", "rst", "textile" ]
let g:pandoc#filetypes#pandoc_markdown = 0
let g:pandoc#filetypes#handled = [ "extra", "latex", "markdown", "pandoc", "rst", "textile"]
" disable all default keymaps
let g:pandoc#keyboard#use_default_mappings=0
" needs to be set for wrapping and unwrapping of lines to work when doing j/k