fix: small improvements
This commit is contained in:
@@ -1,10 +1,22 @@
|
|||||||
-- Modules
|
-- Modules
|
||||||
vim.loader.enable()
|
vim.loader.enable()
|
||||||
vim.opt.runtimepath:remove('/usr/share/nvim/site')
|
vim.opt.runtimepath:remove('/usr/share/nvim/site')
|
||||||
for _, m in ipairs({ 'netrw', 'netrwPlugin', 'gzip', 'tarPlugin', 'zipPlugin', 'tutor_mode_plugin', 'rplugin' }) do
|
for _, m in ipairs({
|
||||||
|
'netrw', 'netrwPlugin',
|
||||||
|
'gzip', 'tarPlugin',
|
||||||
|
'tutor_mode_plugin',
|
||||||
|
'remote_plugins',
|
||||||
|
'nvim_zip_plugin',
|
||||||
|
'nvim_net_plugin',
|
||||||
|
'spellfile_plugin',
|
||||||
|
}) do
|
||||||
vim.g['loaded_' .. m] = 1
|
vim.g['loaded_' .. m] = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for _, p in ipairs({ 'node', 'python3', 'perl', 'ruby' }) do
|
||||||
|
vim.g['loaded_' .. p .. '_provider'] = 0
|
||||||
|
end
|
||||||
|
|
||||||
-- Config Global
|
-- Config Global
|
||||||
vim.pack.add({ 'https://github.com/nvim-mini/mini.nvim' })
|
vim.pack.add({ 'https://github.com/nvim-mini/mini.nvim' })
|
||||||
local misc = require('mini.misc')
|
local misc = require('mini.misc')
|
||||||
|
|||||||
+18
-8
@@ -5,21 +5,31 @@ local function show(buf_id, items, query)
|
|||||||
MiniPick.default_show(buf_id, items, query)
|
MiniPick.default_show(buf_id, items, query)
|
||||||
vim.api.nvim_buf_clear_namespace(buf_id, ns, 0, -1)
|
vim.api.nvim_buf_clear_namespace(buf_id, ns, 0, -1)
|
||||||
for i, item in ipairs(items) do
|
for i, item in ipairs(items) do
|
||||||
local hl = hls[item.text:match('%S')]
|
if item.hl then
|
||||||
if hl then
|
vim.api.nvim_buf_set_extmark(buf_id, ns, i - 1, 1, { end_col = 3, hl_group = item.hl, priority = 202, hl_mode = 'combine' })
|
||||||
vim.api.nvim_buf_set_extmark(buf_id, ns, i - 1, 0, { end_col = 2, hl_group = hl, priority = 202, hl_mode = 'combine' })
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status = function()
|
status = function()
|
||||||
local items = {}
|
local lines = vim.fn.systemlist('git status -s -u')
|
||||||
for _, l in ipairs(vim.fn.systemlist('git status -s -u')) do
|
if vim.v.shell_error ~= 0 then
|
||||||
local p = l:sub(4):gsub('.* %-> ', '')
|
return vim.notify('Not a git repository', vim.log.levels.WARN)
|
||||||
if vim.uv.fs_stat(p) then items[#items + 1] = { text = l, path = p } end
|
|
||||||
end
|
end
|
||||||
if #items == 0 then return vim.notify('No changes') end
|
|
||||||
|
local items = {}
|
||||||
|
for _, l in ipairs(lines) do
|
||||||
|
local s = l:sub(1, 2):match('%S+')
|
||||||
|
local p = l:sub(4):gsub('.* %-> ', ''):gsub('^"(.*)"$', '%1')
|
||||||
|
local hl = l:sub(1, 1) ~= ' ' and l:sub(1, 1) ~= '?' and 'DiagnosticOk' or hls[s:sub(1, 1)]
|
||||||
|
items[#items + 1] = {
|
||||||
|
text = string.format(' %-2s %s', s == '??' and '?' or s, p),
|
||||||
|
path = p,
|
||||||
|
hl = hl,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
if #items == 0 then return vim.notify('No changes', vim.log.levels.INFO) end
|
||||||
|
|
||||||
MiniPick.start({
|
MiniPick.start({
|
||||||
source = { items = items, name = 'Git Status', show = show },
|
source = { items = items, name = 'Git Status', show = show },
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
-- General
|
-- General
|
||||||
vim.g.mapleader = ' ' -- Use `<Space>` as <Leader> key
|
vim.g.mapleader = ' ' -- Use `<Space>` as <Leader> key
|
||||||
vim.o.undofile = true -- Enable persistent undo
|
vim.o.undofile = true -- Enable persistent undo
|
||||||
vim.o.shada = "'100,<50,s10,:1000,/100,@100,h" -- Limit ShaDa file (for startup)
|
vim.o.shada = "'50,<20,s10,:100,/50,@50,h" -- Limit ShaDa file (for startup)
|
||||||
|
|
||||||
-- UI
|
-- UI
|
||||||
vim.o.breakindent = true -- Indent wrapped lines to match line start
|
vim.o.breakindent = true -- Indent wrapped lines to match line start
|
||||||
@@ -9,6 +9,7 @@ vim.o.breakindentopt = 'list:-1' -- Add padding for lists (if 'wrap' is set)
|
|||||||
vim.o.cursorline = true -- Enable current line highlighting
|
vim.o.cursorline = true -- Enable current line highlighting
|
||||||
vim.o.linebreak = true -- Wrap lines at 'breakat' (if 'wrap' is set)
|
vim.o.linebreak = true -- Wrap lines at 'breakat' (if 'wrap' is set)
|
||||||
vim.o.list = true -- Show helpful text indicators
|
vim.o.list = true -- Show helpful text indicators
|
||||||
|
vim.o.listchars = 'tab:→ ,trail:·,nbsp:␣' -- Characters for list mode
|
||||||
vim.o.number = true -- Show line numbers
|
vim.o.number = true -- Show line numbers
|
||||||
vim.o.pumheight = 10 -- Make popup menu smaller
|
vim.o.pumheight = 10 -- Make popup menu smaller
|
||||||
vim.o.pummaxwidth = 80 -- Make popup menu not too wide
|
vim.o.pummaxwidth = 80 -- Make popup menu not too wide
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ end
|
|||||||
|
|
||||||
nmap_leader('ed', '<Cmd>lua MiniFiles.open()<CR>', 'Directory')
|
nmap_leader('ed', '<Cmd>lua MiniFiles.open()<CR>', 'Directory')
|
||||||
nmap_leader('ef', explore_at_file, 'File directory')
|
nmap_leader('ef', explore_at_file, 'File directory')
|
||||||
nmap_leader('ey', '<Cmd>lua vim.fn.setreg("+", vim.api.nvim_buf_get_name(0))<CR>', 'Yank absolute path')
|
nmap_leader('ey', '<Cmd>lua vim.fn.setreg("+", vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":."))<CR>', 'Yank absolute path')
|
||||||
|
nmap_leader('eY', '<Cmd>lua vim.fn.setreg("+", vim.api.nvim_buf_get_name(0))<CR>', 'Yank relative path')
|
||||||
nmap_leader('en', '<Cmd>messages<CR>', 'Notifications')
|
nmap_leader('en', '<Cmd>messages<CR>', 'Notifications')
|
||||||
|
|
||||||
-- Find
|
-- Find
|
||||||
@@ -74,6 +75,7 @@ nmap_leader('fh', '<Cmd>Pick help<CR>', 'Help tags')
|
|||||||
nmap_leader('fl', '<Cmd>Pick buf_lines scope="all"<CR>', 'Lines (all)')
|
nmap_leader('fl', '<Cmd>Pick buf_lines scope="all"<CR>', 'Lines (all)')
|
||||||
nmap_leader('fL', '<Cmd>Pick buf_lines scope="current"<CR>', 'Lines (buf)')
|
nmap_leader('fL', '<Cmd>Pick buf_lines scope="current"<CR>', 'Lines (buf)')
|
||||||
nmap_leader('fm', '<Cmd>Pick git_status<CR>', 'Modified / changed files')
|
nmap_leader('fm', '<Cmd>Pick git_status<CR>', 'Modified / changed files')
|
||||||
|
nmap_leader('fo', '<Cmd>Pick oldfiles<CR>', 'Old / recent files')
|
||||||
nmap_leader('fr', '<Cmd>Pick resume<CR>', 'Resume')
|
nmap_leader('fr', '<Cmd>Pick resume<CR>', 'Resume')
|
||||||
nmap_leader('fs', '<Cmd>Pick lsp scope="workspace_symbol_live"<CR>', 'Symbols workspace')
|
nmap_leader('fs', '<Cmd>Pick lsp scope="workspace_symbol_live"<CR>', 'Symbols workspace')
|
||||||
nmap_leader('fS', '<Cmd>Pick lsp scope="document_symbol"<CR>', 'Symbols document')
|
nmap_leader('fS', '<Cmd>Pick lsp scope="document_symbol"<CR>', 'Symbols document')
|
||||||
|
|||||||
+11
-2
@@ -12,7 +12,16 @@ Config.now(function()
|
|||||||
return vim.iter({ vim.fn.glob('~/Code/*', 0, 1), vim.fn.glob('~/Documents/*/*', 0, 1) })
|
return vim.iter({ vim.fn.glob('~/Code/*', 0, 1), vim.fn.glob('~/Documents/*/*', 0, 1) })
|
||||||
:flatten()
|
:flatten()
|
||||||
:filter(function(p) return vim.fn.isdirectory(p) == 1 end)
|
:filter(function(p) return vim.fn.isdirectory(p) == 1 end)
|
||||||
:map(function(p) return { name = vim.fn.fnamemodify(p, ':t'), action = 'edit ' .. vim.fn.fnameescape(p), section = 'Projects' } end)
|
:map(function(p)
|
||||||
|
return {
|
||||||
|
name = vim.fn.fnamemodify(p, ':t'),
|
||||||
|
action = function()
|
||||||
|
vim.fn.chdir(p)
|
||||||
|
require('mini.files').open(p)
|
||||||
|
end,
|
||||||
|
section = 'Projects',
|
||||||
|
}
|
||||||
|
end)
|
||||||
:totable()
|
:totable()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -47,7 +56,7 @@ Config.later(function()
|
|||||||
{ mode = { 'n', 'x' }, keys = 'g' },
|
{ mode = { 'n', 'x' }, keys = 'g' },
|
||||||
{ mode = { 'n', 'x' }, keys = "'" },
|
{ mode = { 'n', 'x' }, keys = "'" },
|
||||||
{ mode = { 'n', 'x' }, keys = '`' },
|
{ mode = { 'n', 'x' }, keys = '`' },
|
||||||
{ mode = { 'n', 'x' }, keys = "'" },
|
{ mode = { 'n', 'x' }, keys = '"' },
|
||||||
{ mode = { 'i', 'c' }, keys = '<C-r>' },
|
{ mode = { 'i', 'c' }, keys = '<C-r>' },
|
||||||
{ mode = 'n', keys = '<C-w>' },
|
{ mode = 'n', keys = '<C-w>' },
|
||||||
{ mode = { 'n', 'x' }, keys = 's' },
|
{ mode = { 'n', 'x' }, keys = 's' },
|
||||||
|
|||||||
+14
-3
@@ -9,6 +9,8 @@ end)
|
|||||||
|
|
||||||
-- Treesitter
|
-- Treesitter
|
||||||
Config.now_if_args(function()
|
Config.now_if_args(function()
|
||||||
|
vim.treesitter.language.register('bash', 'sh')
|
||||||
|
vim.treesitter.language.register('tsx', 'typescriptreact')
|
||||||
|
|
||||||
local filetypes = {
|
local filetypes = {
|
||||||
'html', 'css', 'lua', 'go', 'php', 'blade', 'sql', 'javascript',
|
'html', 'css', 'lua', 'go', 'php', 'blade', 'sql', 'javascript',
|
||||||
@@ -23,10 +25,19 @@ Config.now_if_args(function()
|
|||||||
end, 'Start tree-sitter')
|
end, 'Start tree-sitter')
|
||||||
|
|
||||||
Config.later(function()
|
Config.later(function()
|
||||||
|
local missing = {}
|
||||||
|
|
||||||
|
for _, ft in ipairs(filetypes) do
|
||||||
|
local lang = vim.treesitter.language.get_lang(ft) or ft
|
||||||
|
if #vim.api.nvim_get_runtime_file('parser/' .. lang .. '.so', false) == 0 then
|
||||||
|
table.insert(missing, lang)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #missing > 0 then
|
||||||
vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter' })
|
vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter' })
|
||||||
require('nvim-treesitter').install(vim.tbl_map(function(ft)
|
require('nvim-treesitter').install(missing)
|
||||||
return vim.treesitter.language.get_lang(ft) or ft
|
end
|
||||||
end, filetypes))
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user