WIP
This commit is contained in:
parent
bda064af13
commit
efb0c3e083
@ -1,60 +0,0 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
|
||||
"Lua.workspace.library": [
|
||||
"/home/alex/.config/vim/pack/plugins/start/neodev.nvim/types/stable",
|
||||
"/usr/share/nvim/runtime",
|
||||
"/home/alex/.config/vim/pack/plugins/start/Comment.nvim",
|
||||
"/home/alex/.config/vim/pack/plugins/start/cmp-nvim-lsp",
|
||||
"/home/alex/.config/vim/pack/plugins/start/cmp-nvim-lsp-signature-help",
|
||||
"/home/alex/.config/vim/pack/plugins/start/cmp-vsnip",
|
||||
"/home/alex/.config/vim/pack/plugins/start/hflip.nvim",
|
||||
"/home/alex/.config/vim/pack/plugins/start/lualine.nvim",
|
||||
"/home/alex/.config/vim/pack/plugins/start/neodev.nvim",
|
||||
"/home/alex/.config/vim/pack/plugins/start/nightfox.nvim",
|
||||
"/home/alex/.config/vim/pack/plugins/start/nvim-cmp",
|
||||
"/home/alex/.config/vim/pack/plugins/start/nvim-lspconfig",
|
||||
"/home/alex/.config/vim/pack/plugins/start/plenary.nvim",
|
||||
"/home/alex/.config/nvim",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/Comment.nvim",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/cmp-nvim-lsp",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/cmp-nvim-lsp-signature-help",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/cmp-vsnip",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/fzf",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/fzf.vim",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/hflip.nvim",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/lualine.nvim",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/neodev.nvim",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/nightfox.nvim",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/nvim-cmp",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/nvim-lspconfig",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/plenary.nvim",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/suda.vim",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-abolish",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-angry",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-argwrap",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-better-whitespace",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-dirvish",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-easy-align",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-fugitive",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-go",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-indent-object",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-interestingwords",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-polyglot",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-repeat",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-rooter",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-signify",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-sort-motion",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-surround",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-unimpaired",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-vsnip",
|
||||
"/usr/share/nvim/site",
|
||||
"/usr/share/nvim/runtime",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/cmp-nvim-lsp/after",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/cmp-nvim-lsp-signature-help/after",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/cmp-vsnip/after",
|
||||
"/home/alex/.config/nvim/pack/plugins/start/vim-polyglot/after",
|
||||
"/usr/bin/../share/nvim-qt/runtime",
|
||||
"/usr/share/vim/vimfiles/",
|
||||
"${3rd}/luassert/library"
|
||||
]
|
||||
}
|
@ -1,39 +1,92 @@
|
||||
-- local function closest_range(pos, range1, range2)
|
||||
-- rowDiff = range1
|
||||
--
|
||||
-- end
|
||||
--
|
||||
local ArgonautConfig = {
|
||||
line_prefix = '',
|
||||
padded_braces = {},
|
||||
tail_comma = false,
|
||||
tail_comma_braces = {},
|
||||
tail_indent_braces = {},
|
||||
wrap_closing_brace = true,
|
||||
comma_first = false,
|
||||
comma_first_indent = false,
|
||||
}
|
||||
|
||||
local function get_cursor_pos()
|
||||
local _, row, col, _ = unpack(vim.fn.getpos('.'))
|
||||
return {row = row, col = col}
|
||||
local function setup(opts)
|
||||
if opts then
|
||||
for key, value in pairs(opts) do
|
||||
ArgonautConfig[key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function find_range(brace_pair)
|
||||
local filter = 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'
|
||||
local start = vim.fn.searchpairpos(brace_pair[0], '', brace_pair[1], 'Wnb', filter)
|
||||
local stop = vim.fn.searchpairpos(brace_pair[0], '', brace_pair[1], 'Wcn', filter)
|
||||
return {row1 = start[1], col1 = start[2], row2 = stop[1], col2 = stop[2]}
|
||||
local row1, col1 = unpack(vim.fn.searchpairpos(brace_pair[1], '', brace_pair[2], 'Wnb', filter))
|
||||
if row1 > 0 and col1 > 0 then
|
||||
local row2, col2 = unpack(vim.fn.searchpairpos(brace_pair[1], '', brace_pair[2], 'Wcn', filter))
|
||||
if row2 > 0 and col2 > 0 then
|
||||
return {
|
||||
brace_pair = brace_pair,
|
||||
row1 = row1,
|
||||
col1 = col1,
|
||||
row2 = row2,
|
||||
col2 = col2
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function find_ranges(brace_pairs)
|
||||
local ranges = {}
|
||||
for _, brace_pair in ipairs(brace_pairs) do
|
||||
table.insert(ranges, find_range(brace_pair))
|
||||
local range = find_range(brace_pair)
|
||||
if range then
|
||||
table.insert(ranges, find_range(brace_pair))
|
||||
end
|
||||
end
|
||||
|
||||
if #ranges > 0 then
|
||||
return ranges
|
||||
end
|
||||
return ranges
|
||||
end
|
||||
|
||||
local function find_range_closest(brace_pairs, pos)
|
||||
local function compare_ranges(range1, range2)
|
||||
local _, row, col, _ = unpack(vim.fn.getpos('.'))
|
||||
|
||||
local row_diff1 = row - range1.row1
|
||||
local row_diff2 = row - range2.row1
|
||||
if row_diff1 < row_diff2 then
|
||||
return -1
|
||||
elseif row_diff1 > row_diff2 then
|
||||
return 1
|
||||
end
|
||||
|
||||
local col_diff1 = col - range1.col1
|
||||
local col_diff2 = col - range2.col1
|
||||
if col_diff1 < col_diff2 then
|
||||
return -1
|
||||
elseif col_diff1 > col_diff2 then
|
||||
return 1
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
local function find_range_closest(brace_pairs)
|
||||
local ranges = find_ranges(brace_pairs)
|
||||
return ranges[0]
|
||||
print(#ranges)
|
||||
if ranges then
|
||||
return vim.fn.sort(ranges, compare_ranges)[1]
|
||||
end
|
||||
end
|
||||
|
||||
local function wrap_toggle()
|
||||
local brace_pairs = {{'(', ')'}, {'[', ']'}, {'{', '}'}}
|
||||
find_range_closest(get_cursor_pos(), brace_pairs)
|
||||
local function reflow()
|
||||
local brace_pairs = {{'(', ')'}, {'[', ']'}, {'{', '}'}, {'<', '>'}}
|
||||
local range = find_range_closest(brace_pairs)
|
||||
if range then
|
||||
print(range.brace_pair[1])
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
wrap_toggle = wrap_toggle
|
||||
reflow = reflow,
|
||||
ssetup = setup,
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
local argonaut = require('argonaut')
|
||||
|
||||
local function argonaut_reload()
|
||||
package.loaded.argonaut = nil
|
||||
argonaut = require('argonaut')
|
||||
end
|
||||
|
||||
local function argonaut_wrap_toggle()
|
||||
argonaut_reload()
|
||||
argonaut.wrap_toggle()
|
||||
end
|
||||
|
||||
if not vim.g.argonaut then
|
||||
local argonaut = require('argonaut')
|
||||
|
||||
local function argonaut_reload()
|
||||
package.loaded.argonaut = nil
|
||||
argonaut = require('argonaut')
|
||||
end
|
||||
|
||||
local function argonaut_reflow()
|
||||
argonaut_reload()
|
||||
argonaut.reflow()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('ArgonautReload', argonaut_reload, {})
|
||||
vim.api.nvim_create_user_command('ArgonautWrapToggle', argonaut_wrap_toggle, {})
|
||||
vim.api.nvim_create_user_command('ArgonautReflow', argonaut_reflow, {})
|
||||
|
||||
vim.g.argonaut = true
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user