add undotree mapping, format

This commit is contained in:
2023-06-04 12:13:11 +03:00
parent b424ac2685
commit 64d948cdf3
8 changed files with 99 additions and 80 deletions

View File

@@ -61,4 +61,3 @@ vim.cmd("ab thursday Thursday")
vim.cmd("ab friday Friday")
vim.cmd("ab saturday Saturday")
vim.cmd("ab sunday Sunday")

View File

@@ -8,11 +8,14 @@ M.config = function()
-- we fall back to the various language tools installed with pwnvim using this hack
local initial_path = vim.env.PATH
autocmd("User DirenvLoaded",
{ callback = function()
if not string.find(vim.env.PATH, initial_path, 0, true) then
vim.env.PATH = vim.env.PATH .. ":" .. initial_path
end
end, group = filetypes })
{
callback = function()
if not string.find(vim.env.PATH, initial_path, 0, true) then
vim.env.PATH = vim.env.PATH .. ":" .. initial_path
end
end,
group = filetypes
})
autocmd("BufRead", { pattern = { "*.markdown", "*.md" }, command = "setlocal filetype=markdown", group = filetypes })
autocmd("BufRead", { pattern = { "*.sbt" }, command = "setlocal filetype=scala", group = filetypes })
@@ -25,28 +28,39 @@ M.config = function()
autocmd("BufRead", { pattern = { "flake.lock" }, command = "setlocal filetype=json", group = filetypes })
autocmd("FileType",
{ pattern = { "sql", "mysql", "plsql" },
{
pattern = { "sql", "mysql", "plsql" },
callback = function() require('cmp').setup.buffer({ sources = { { name = 'vim-dadbod-completion' } } }) end,
group = filetypes })
group = filetypes
})
autocmd("FileType",
{ pattern = { "c", "ruby", "php", "php3", "perl", "python", "mason", "vim", "sh", "zsh", "scala", "javascript",
"javascriptreact", "typescript", "typescriptreact", "html", "svelte", "css", "nix", "terraform" },
callback = function() require('pwnvim.options').programming() end, group = filetypes })
{
pattern = { "c", "ruby", "php", "php3", "perl", "python", "mason", "vim", "sh", "zsh", "scala", "javascript",
"javascriptreact", "typescript", "typescriptreact", "html", "svelte", "css", "nix", "terraform" },
callback = function() require('pwnvim.options').programming() end,
group = filetypes
})
autocmd("FileType",
{ pattern = { "lua", "xml" }, callback = function() require('pwnvim.filetypes').lua() end, group = filetypes })
autocmd("FileType",
{ pattern = { "md", "markdown", "vimwiki" }, callback = function() require('pwnvim.markdown').setup() end,
group = filetypes })
-- autocmd("FileType",
-- { pattern = { "rust" }, callback = function() require('pwnvim.filetypes').rust() end, group = filetypes })
{
pattern = { "md", "markdown", "vimwiki" },
callback = function() require('pwnvim.markdown').setup() end,
group = filetypes
})
-- autocmd("FileType",
-- { pattern = { "rust" }, callback = function() require('pwnvim.filetypes').rust() end, group = filetypes })
autocmd("FileType",
{ pattern = { "Outline" }, command = "setlocal nospell", group = filetypes })
autocmd("TermOpen", { pattern = { "*" }, command = "setlocal nospell", group = filetypes })
-- Run when page pager is invoked
autocmd('User',
{ pattern = { 'PageOpen', 'PageOpenFile' }, group = filetypes,
callback = function() require('pwnvim.filetypes').page() end })
{
pattern = { 'PageOpen', 'PageOpenFile' },
group = filetypes,
callback = function() require('pwnvim.filetypes').page() end
})
end
-- M.rust = function()

View File

@@ -2,51 +2,51 @@
local which_key = require("which-key")
which_key.setup({
plugins = {
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
marks = true, -- shows a list of your marks on ' and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
spelling = {
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
suggestions = 20 -- how many suggestions should be shown in the list?
},
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
presets = {
operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion
motions = false, -- adds help for motions
operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion
motions = false, -- adds help for motions
text_objects = true, -- help for text objects triggered after entering an operator
windows = true, -- default bindings on <c-w>
nav = true, -- misc bindings to work with windows
z = true, -- bindings for folds, spelling and others prefixed with z
g = true -- bindings for prefixed with g
windows = true, -- default bindings on <c-w>
nav = true, -- misc bindings to work with windows
z = true, -- bindings for folds, spelling and others prefixed with z
g = true -- bindings for prefixed with g
}
},
icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
separator = "", -- symbol used between a key and it's label
group = "+" -- symbol prepended to a group
group = "+" -- symbol prepended to a group
},
popup_mappings = {
scroll_down = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>" -- binding to scroll up inside the popup
scroll_up = "<c-u>" -- binding to scroll up inside the popup
},
window = {
border = "rounded", -- none, single, double, shadow
position = "bottom", -- bottom, top
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
border = "rounded", -- none, single, double, shadow
position = "bottom", -- bottom, top
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
winblend = 0
},
layout = {
height = { min = 4, max = 25 }, -- min and max height of the columns
width = { min = 20, max = 50 }, -- min and max width of the columns
spacing = 3, -- spacing between columns
align = "left" -- align columns left, center or right
spacing = 3, -- spacing between columns
align = "left" -- align columns left, center or right
},
ignore_missing = true, -- enable this to hide mappings for which you didn't specify a label
ignore_missing = true, -- enable this to hide mappings for which you didn't specify a label
hidden = {
"<silent>", "<CMD>", "<cmd>", "<Cmd>", "<cr>", "<CR>", "call", "lua",
"^:", "^ "
}, -- hide mapping boilerplate
}, -- hide mapping boilerplate
show_help = true, -- show help message on the command line when the popup is visible
triggers = "auto" -- automatically setup triggers
-- triggers = {"<leader>"} -- or specify a list manually
@@ -116,20 +116,20 @@ vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
local global_leader_opts = {
mode = "n", -- NORMAL mode
mode = "n", -- NORMAL mode
prefix = "<leader>",
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
noremap = true, -- use `noremap` when creating keymaps
nowait = true -- use `nowait` when creating keymaps
nowait = true -- use `nowait` when creating keymaps
}
local global_leader_opts_visual = {
mode = "v", -- VISUAL mode
mode = "v", -- VISUAL mode
prefix = "<leader>",
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
noremap = true, -- use `noremap` when creating keymaps
nowait = true -- use `nowait` when creating keymaps
nowait = true -- use `nowait` when creating keymaps
}
local leader_mappings = {
@@ -153,7 +153,8 @@ local leader_mappings = {
l = { "<cmd>lua require('telescope.builtin').loclist()<cr>", "Loclist" },
p = { "<cmd>Telescope projects<cr>", "Projects" },
k = { "<cmd>Telescope keymaps<cr>", "Keymaps" },
t = { "<cmd>lua require('telescope.builtin').grep_string{search = \"^\\\\s*[*-] \\\\[ \\\\]\", previewer = false, glob_pattern = \"*.md\", use_regex = true, disable_coordinates=true}<cr>",
t = {
"<cmd>lua require('telescope.builtin').grep_string{search = \"^\\\\s*[*-] \\\\[ \\\\]\", previewer = false, glob_pattern = \"*.md\", use_regex = true, disable_coordinates=true}<cr>",
"Todos" },
n = { "<Cmd>ZkNotes { match = {vim.fn.input('Search: ')} }<CR>", "Find" },
},
@@ -198,10 +199,12 @@ local leader_mappings = {
},
h = { "<cmd>edit ~/Notes/Notes/HotSheet.md<CR>", "Open HotSheet" },
i = {
c = { "<cmd>r!/opt/homebrew/bin/icalBuddy --bullet '* ' --timeFormat '\\%H:\\%M' --dateFormat '' --noPropNames --noCalendarNames --excludeAllDayEvents --includeCals 'IC - Work' --includeEventProps datetime,title,attendees,location --propertyOrder datetime,title,attendees,location --propertySeparators '| |\\n * |\\n * | |' eventsToday<cr>",
c = {
"<cmd>r!/opt/homebrew/bin/icalBuddy --bullet '* ' --timeFormat '\\%H:\\%M' --dateFormat '' --noPropNames --noCalendarNames --excludeAllDayEvents --includeCals 'IC - Work' --includeEventProps datetime,title,attendees,location --propertyOrder datetime,title,attendees,location --propertySeparators '| |\\n * |\\n * | |' eventsToday<cr>",
"Insert today's calendar" },
o = { "<cmd>r!gtm-okr goals<cr>", "Insert OKRs" },
j = { "<cmd>r!( (curl -s https://icanhazdadjoke.com/ | grep '\\\"subtitle\\\"') || curl -s https://icanhazdadjoke.com/ ) | sed 's/<[^>]*>//g' | sed -z 's/\\n/ /'<cr>",
j = {
"<cmd>r!( (curl -s https://icanhazdadjoke.com/ | grep '\\\"subtitle\\\"') || curl -s https://icanhazdadjoke.com/ ) | sed 's/<[^>]*>//g' | sed -z 's/\\n/ /'<cr>",
"Insert joke" },
},
m = {
@@ -456,6 +459,9 @@ which_key.register({
}, { mode = 'n', silent = true })
-- Undotree
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
-- Close buffer
vim.api.nvim_set_keymap('', '<D-w>', ':Bdelete<CR>', options)
vim.api.nvim_set_keymap('!', '<D-w>', '<ESC>:Bdelete<CR>', options)

View File

@@ -1,7 +1,7 @@
local M = {}
SimpleUI = (os.getenv("SIMPLEUI") == "1" or os.getenv("TERM_PROGRAM") ==
"Apple_Terminal" or os.getenv("TERM") == "linux") and
"Apple_Terminal" or os.getenv("TERM") == "linux") and
not vim.g.neovide
M.defaults = function()
@@ -11,7 +11,7 @@ M.defaults = function()
vim.g.loaded_tarPlugin = 0
vim.g.loaded_zipPlugin = 0
vim.g.loaded_2html_plugin = 0
vim.g.loaded_netrw = 1 -- disable netrw
vim.g.loaded_netrw = 1 -- disable netrw
vim.g.loaded_netrwPlugin = 1 -- disable netrw
-- we just use lua plugins here so disable others
vim.g.loaded_perl_provider = 0
@@ -44,26 +44,26 @@ M.defaults = function()
-- ignore completions and menus for the below
vim.opt.wildignore =
"*/node_modules/*,_site,*/__pycache__/,*/venv/*,*/target/*,*/.vim$,\\~$,*/.log,*/.aux,*/.cls,*/.aux,*/.bbl,*/.blg,*/.fls,*/.fdb*/,*/.toc,*/.out,*/.glo,*/.log,*/.ist,*/.fdb_latexmk,*.bak,*.o,*.a,*.sw?,.git/,*.class,.direnv/,.DS_Store"
vim.opt.wildmenu = true -- cmd line completion a-la zsh
vim.opt.wildmenu = true -- cmd line completion a-la zsh
vim.opt.wildmode = "list:longest" -- matches mimic that of bash or zsh
vim.opt.swapfile = false
vim.opt.spell = true
vim.opt.spelllang = "en_us"
vim.opt.ruler = true -- show the cursor position all the time
vim.opt.ruler = true -- show the cursor position all the time
vim.opt.cursorline = true -- add indicator for current line
vim.opt.secure = true -- don't execute shell cmds in .vimrc not owned by me
vim.opt.history = 50 -- keep 50 lines of command line history
vim.opt.secure = true -- don't execute shell cmds in .vimrc not owned by me
vim.opt.history = 50 -- keep 50 lines of command line history
vim.opt.shell = "zsh"
vim.opt.modelines = 0 -- Don't allow vim settings embedded in text files for security reasons
vim.opt.showcmd = true -- display incomplete commands
vim.opt.showmode = true -- display current mode
vim.opt.modelines = 0 -- Don't allow vim settings embedded in text files for security reasons
vim.opt.showcmd = true -- display incomplete commands
vim.opt.showmode = true -- display current mode
-- with backup off and writebackup on: backup current file, deleted afterwards
vim.opt.backup = false
vim.opt.writebackup = true
vim.opt.backupcopy = "auto"
vim.opt.hidden = true
vim.opt.cf = true -- jump to errors based on error files
vim.opt.cf = true -- jump to errors based on error files
vim.o.listchars = "tab:⇥ ,trail:␣,extends:⇉,precedes:⇇,nbsp:·"
vim.opt.list = true -- render special chars (tabs, trails, ...)
vim.opt.ttyfast = true
@@ -75,7 +75,7 @@ M.defaults = function()
vim.opt.complete = vim.opt.complete - { 'i' }
vim.opt.encoding = "utf-8"
vim.opt.backspace = "indent,eol,start" -- allow backspacing over everything in insert mode
vim.opt.joinspaces = false -- don't insert two spaces after sentences on joins
vim.opt.joinspaces = false -- don't insert two spaces after sentences on joins
vim.opt.binary = false
vim.opt.display = "lastline"
vim.opt.viewoptions = "folds,cursor,unix,slash" -- better unix / windows compatibility
@@ -84,8 +84,8 @@ M.defaults = function()
-- wrapping
vim.opt.wrap = true
vim.opt.sidescroll = 2 -- min number of columns to scroll from edge
vim.opt.scrolloff = 8 -- when 4 away from edge start scrolling
vim.opt.sidescroll = 2 -- min number of columns to scroll from edge
vim.opt.scrolloff = 8 -- when 4 away from edge start scrolling
vim.opt.sidescrolloff = 8 -- keep cursor one col from end of line
vim.opt.textwidth = 0
vim.opt.breakindent = true
@@ -97,23 +97,23 @@ M.defaults = function()
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = true -- turn tabs to spaces by default
vim.opt.expandtab = true -- turn tabs to spaces by default
vim.opt.autoindent = true -- autoindent to same level as previous line
vim.opt.autoindent = true -- autoindent to same level as previous line
vim.opt.smartindent = true -- indent after { and cinwords words
vim.opt.smartcase = true -- intelligently ignore case in searches
vim.opt.ignorecase = true -- default to not being case sensitive
vim.opt.smartcase = true -- intelligently ignore case in searches
vim.opt.ignorecase = true -- default to not being case sensitive
vim.opt.smarttab = true
vim.opt.icm = "nosplit" -- show substitutions as you type
vim.opt.icm = "nosplit" -- show substitutions as you type
vim.opt.hlsearch = true
vim.opt.updatetime = 250 -- Decrease update time
vim.opt.updatetime = 250 -- Decrease update time
vim.wo.signcolumn = 'yes'
vim.opt.visualbell = true
vim.opt.autoread = true -- auto reload files changed on disk if not changed in buffer
vim.opt.cursorline = false
vim.opt.ttyfast = true
vim.opt.formatoptions = 'jcroqlt' -- t=text, c=comments, q=format with "gq"
vim.opt.showmatch = true -- auto hilights matching bracket or paren
vim.opt.showmatch = true -- auto hilights matching bracket or paren
vim.opt.nrformats = vim.opt.nrformats - { 'octal' }
vim.opt.shiftround = true
vim.opt.ttimeout = true
@@ -283,7 +283,7 @@ M.defaults = function()
TelescopeNormal = { bg = "${telescope_results}" },
TelescopeSelection = { bg = "${telescope_prompt}" }
},
styles = { -- Choose from "bold,italic,underline"
styles = { -- Choose from "bold,italic,underline"
virtual_text = "italic" -- Style that is applied to virtual text
},
plugins = { all = true },

View File

@@ -351,7 +351,7 @@ M.diagnostics = function()
capabilities = capabilities
}
lspconfig.terraformls.setup { on_attach = attached, capabilities = capabilities } -- terraform lsp
lspconfig.tflint.setup { on_attach = attached, capabilities = capabilities } -- terraform lsp
lspconfig.tflint.setup { on_attach = attached, capabilities = capabilities } -- terraform lsp
require 'lspsaga'.init_lsp_saga({
use_saga_diagnostic_sign = not SimpleUI,

View File

@@ -19,7 +19,7 @@ require('lualine').setup {
sources = { 'nvim_diagnostic' },
-- displays diagnostics from defined severity
sections = { 'error', 'warn' }, -- 'info', 'hint'},}}
color_error = "#E06C75", -- changes diagnostic's error foreground color
color_error = "#E06C75", -- changes diagnostic's error foreground color
color_warn = "#E5C07B"
}
}

View File

@@ -6,8 +6,8 @@ require("todo-comments").setup {
signs = false, -- show icons in the signs column
keywords = {
FIX = {
icon = "", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below)
icon = "", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below)
alt = { "ERROR", "FIXME", "BUG", "FIXIT", "ISSUE", "!!!" }, -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually
},
@@ -25,13 +25,13 @@ require("todo-comments").setup {
-- * after: highlights after the keyword (todo text)
highlight = {
multiline = false,
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide" or empty. (wide is the same as bg, but will also highlight surrounding characters)
after = "fg", -- "fg" or "bg" or empty
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide" or empty. (wide is the same as bg, but will also highlight surrounding characters)
after = "fg", -- "fg" or "bg" or empty
pattern = [[<(KEYWORDS)]], -- pattern or table of patterns, used for highlightng (vim regex)
comments_only = false, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
comments_only = false, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
-- list of named colors where we try to extract the guifg from the
-- list of hilight groups or use the hex color if hl not found as a fallback

View File

@@ -6,9 +6,9 @@ M.hint = SimpleUI and "" or ""
M.info = SimpleUI and "" or ""
M.signs = {
{ name = "DiagnosticSignError", text = M.error },
{ name = "DiagnosticSignWarn", text = M.warn },
{ name = "DiagnosticSignHint", text = M.hint },
{ name = "DiagnosticSignInfo", text = M.info }
{ name = "DiagnosticSignWarn", text = M.warn },
{ name = "DiagnosticSignHint", text = M.hint },
{ name = "DiagnosticSignInfo", text = M.info }
}
if SimpleUI then
M.kind_icons = {