summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/10_options.lua4
-rw-r--r--plugin/11_keymaps.lua46
-rw-r--r--plugin/12_autocommands.lua6
-rw-r--r--plugin/plugins/gitsigns.lua1
-rw-r--r--plugin/plugins/mini.lua94
5 files changed, 130 insertions, 21 deletions
diff --git a/plugin/10_options.lua b/plugin/10_options.lua
index ce3b235..f56dc6c 100644
--- a/plugin/10_options.lua
+++ b/plugin/10_options.lua
@@ -48,6 +48,4 @@ vim.g.tex_no_error = 1
vim.g.tex_comment_nospell = 1
vim.opt.tags:append({ "tags;~", ".tags;~" })
-vim.o.laststatus = 1
-vim.o.statusline = "%<%f %h%w%m%r %=%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}%{% &busy > 0 ? '◐ ' : '' %}%{% luaeval('(package.loaded[''vim.diagnostic''] and #vim.diagnostic.count() ~= 0 and vim.diagnostic.status() .. '' '') or '''' ') %}%{% v:lua.require'mo.statusline'.lsp_status() %}%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}"
-
+vim.o.laststatus = 2
diff --git a/plugin/11_keymaps.lua b/plugin/11_keymaps.lua
index 9dcd4f4..9758fb3 100644
--- a/plugin/11_keymaps.lua
+++ b/plugin/11_keymaps.lua
@@ -1,3 +1,6 @@
+-- vim: foldmethod=marker
+
+-- stylua: ignore start
local map = function(mode, lhs, rhs, desc) vim.keymap.set(mode, lhs, rhs, { desc = desc }) end
local nmap = function(lhs, rhs, desc) map("n", lhs, rhs, desc) end
local mapleader = function(mode, suffix, rhs, desc) map(mode, "<Leader>" .. suffix, rhs, desc) end
@@ -21,38 +24,59 @@ vim.keymap.set({ "n", "x" }, "k", [[v:count == 0 ? 'gk' : 'k']], { expr = true,
nmap("gK", "K", "use the keywordprg instead of hover")
-map('t', '<C-[>', [[<C-\><C-N>]], "go to normal mode from terminal mode")
-map('t', '<Esc>', '<Esc>', "map <Esc> to literal ESC in terminal mode")
+map("t", "<C-[>", [[<C-\><C-N>]], "go to normal mode from terminal mode")
+map("t", "<Esc>", "<Esc>", "map <Esc> to literal ESC in terminal mode")
+
+-- stylua: ignore end
--- lua exec
+-- lua exec {{{
nmapleader("x", function()
- local line = "lua " .. vim.api.nvim_get_current_line()
- vim.api.nvim_command(line)
- vim.api.nvim_input("<Down>")
+ local line = "lua " .. vim.api.nvim_get_current_line()
+ vim.api.nvim_command(line)
+ vim.api.nvim_input("<Down>")
end, "execute lua line and go to next line")
+
mapleader("x", "x", ":lua<CR>")
nmap("<Leader><Leader>x", "<Cmd>luafile %<CR>")
+-- }}}
--- lsp and format
+-- lsp and format {{{
nmapleader("e", "<Cmd>lua vim.diagnostic.open_float()<CR>")
nmap("gd", "<Cmd>lua vim.lsp.buf.definition()<CR>")
nmap("<C-f>", "<Cmd>lua require'conform'.format{async=true}<CR>")
+-- }}}
--- fzf
+-- fzf {{{
+-- stylua: ignore start
nmap("<C-p>", "<Cmd>FzfLua files<CR>", "fzf: find files")
nmap("<C-t>", "<Cmd>FzfLua resume<CR>", "fzf: resume")
nmap("<C-\\>", "<Cmd>FzfLua buffers<CR>", "fzf: buffers")
nmap("<C-/>", "<Cmd>FzfLua oldfiles<CR>", "fzf: oldfiles")
-nmapleader("fg", "<Cmd>FzfLua live_grep_native<CR>", "fzf: grep")
-nmapleader("fc", '<Cmd>FzfLua files prompt="Nvim Config>\\ " cwd=~/.config/nvim<CR>', "fzf: search config")
-nmapleader("fp", '<Cmd>lua FzfLua.files({cwd=vim.fn.stdpath("data").."/site/pack/core/opt/"})<CR>', "fzf: search plugins")
+nmapleader("fg", "<Cmd>FzfLua live_grep<CR>", "fzf: grep")
+nmapleader("fc", "<Cmd>FzfLua files cwd=~/.config/nvim<CR>", "fzf: search config")
+nmapleader("fp", "<Cmd>FzfLua files cwd=~/.local/share/nvim/site/pack/core/opt<CR>", "fzf: search plugins")
nmapleader("fh", "<Cmd>FzfLua helptags<CR>", "fzf: help tags")
nmapleader("fk", "<Cmd>FzfLua keymaps<CR>", "fzf: keymaps")
+-- stylua: ignore end
+-- }}}
+
+-- fzf misc {{{
map("n", "z=", "<Cmd>FzfLua spell_suggest<CR>", "fzf: suggest spelling")
+vim.keymap.set("i", "<C-x><C-f>", function()
+ vim.cmd([[packadd fzf-lua]])
+ require("fzf-lua").complete_file({
+ cmd = "rg --files",
+ winopts = { preview = { hidden = true } },
+ })
+end, { silent = true, desc = "fzf: complete file" })
+-- }}}
+
-- git
nmapleader("gs", "<Cmd>Git<CR>", "git status")
-- qf
+-- stylua: ignore start
nmapleader("q", function() require("quicker").toggle() end, "Toggle quickfix list")
+-- stylua: ignore end
diff --git a/plugin/12_autocommands.lua b/plugin/12_autocommands.lua
index 829ed97..73bce84 100644
--- a/plugin/12_autocommands.lua
+++ b/plugin/12_autocommands.lua
@@ -27,12 +27,6 @@ au("LspAttach", {
desc = "add sign column when LSP is attached and redraw status",
})
-au("LspDetach", {
- group = group,
- command = "redrawstatus",
- desc = "redraw status when LSP is dettached",
-})
-
au("FileType", {
group = group,
pattern = "fugitive,git,help,man,qf,query,scratch",
diff --git a/plugin/plugins/gitsigns.lua b/plugin/plugins/gitsigns.lua
new file mode 100644
index 0000000..d16d238
--- /dev/null
+++ b/plugin/plugins/gitsigns.lua
@@ -0,0 +1 @@
+require("gitsigns").setup()
diff --git a/plugin/plugins/mini.lua b/plugin/plugins/mini.lua
index 24027e0..92f86c6 100644
--- a/plugin/plugins/mini.lua
+++ b/plugin/plugins/mini.lua
@@ -32,6 +32,98 @@ vim.schedule(function()
})
end)
+vim.schedule(function() require("mini.icons").setup() end)
+
+local section_filename = function()
+ local st = "%{% &busy > 0 ? '◐ ' : '' %}"
+ -- In terminal always use plain name
+ if vim.bo.buftype == "terminal" then
+ return st .. "%t"
+ elseif _G.MiniStatusline.is_truncated(140) then
+ -- File name with 'truncate', 'modified', 'readonly' flags
+ -- Use relative path if truncated
+ return st .. "%f%m%r"
+ else
+ -- Use fullpath if not truncated
+ return st .. "%F%m%r"
+ end
+end
+
+local section_git = function()
+ if _G.MiniStatusline.is_truncated(40) then return "" end
+ local summary = vim.b.gitsigns_head
+ if summary == nil then return "" end
+ return " " .. (summary == "" and "-" or summary)
+end
+
+local section_diff = function()
+ if _G.MiniStatusline.is_truncated(75) then return "" end
+ local summary = vim.b.gitsigns_status
+ if summary == nil then return "" end
+ return (summary == "" and "-" or summary)
+end
+
+local my_diag_status = function(hl_end)
+ local diag = vim.diagnostic
+ local counts = diag.count(0)
+ local signs = { "E", "W", "I", "H" }
+ local hl_map = {
+ [diag.severity.ERROR] = "DiagSLError",
+ [diag.severity.WARN] = "DiagSLWarn",
+ [diag.severity.INFO] = "DiagSLInfo",
+ [diag.severity.HINT] = "DiagSLHint",
+ }
+ local result_str = vim.iter(pairs(counts))
+ :map(
+ function(severity, count)
+ return ("%%#%s#%s:%s"):format(
+ hl_map[severity],
+ signs[severity],
+ count
+ )
+ end
+ )
+ :join(" ")
+ if result_str:len() > 0 then
+ result_str = result_str .. "%##%#" .. hl_end .. "#"
+ end
+ return result_str
+end
+
+local section_diagnostics = function()
+ if _G.MiniStatusline.is_truncated(75) then return "" end
+ if package.loaded["vim.diagnostic"] and #vim.diagnostic.count() ~= 0 then
+ return my_diag_status("SLDev")
+ end
+ return ""
+end
+
vim.schedule(function()
- require("mini.icons").setup()
+ local statusline = require("mini.statusline")
+ statusline.setup({
+ content = {
+ active = function()
+ local git = section_git()
+ local diff = section_diff()
+ local diagnostics = section_diagnostics()
+
+ local lsp = statusline.section_lsp({ trunc_width = 75 })
+ local filename = section_filename()
+ local fileinfo = vim.bo.filetype
+ local location = "%-6.(%l,%c%V%) %P"
+ -- "%{% &ruler ? ( &rulerformat == '' ? '' : &rulerformat ) : '' %}"
+
+ return statusline.combine_groups({
+ { hl = "SLFilename", strings = { filename } },
+ "%=", -- End left alignment
+ { hl = "SLDev", strings = { git, diff, diagnostics, lsp } },
+ "%<", -- Mark general truncate point
+ { hl = "SLFileInfo", strings = { fileinfo } },
+ { hl = "SLLocation", strings = { location } },
+ })
+ end,
+ inactive = nil,
+ },
+ use_icons = true,
+ })
end)