Compare commits

...

10 commits

Author SHA1 Message Date
b86d963a92 flake: checks: enable 'stylua'
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2023-05-07 13:36:10 +01:00
78c524e19d project: add stylua configuration 2023-05-07 13:36:10 +01:00
1e9f6fe957 home: vim: fix lua formatting 2023-05-07 13:36:10 +01:00
c2d231d3f1 home: vim: use actual lua files
Since most of the settings are actually just lua in a VimL file.
2023-05-07 13:36:10 +01:00
9530864b10 home: vim: fastfold: use lua configuration 2023-05-07 13:36:10 +01:00
e599a97e45 home: vim: abbreviations: use lua
This makes it less repetitive.
2023-05-07 13:36:10 +01:00
39c2e5db8c home: vim: signtoggle: use lua autocommands
A nice next step would be to use actual lua callbacks instead of the
VimL command.
2023-05-07 13:36:10 +01:00
dba8836381 home: vim: numbertoggle: use lua autocommands
A nice next step would be to use actual lua callbacks instead of the
VimL command.
2023-05-07 13:36:10 +01:00
36b0c67832 home: vim: completion: use lua settings 2023-05-07 13:33:02 +01:00
68b9c3b9b1 home: vim: remove 'vim-pandoc'
The tree-sitter code-block high-lighting is built-in and works better,
and I don't use any of the other features.
2023-05-07 13:04:37 +01:00
32 changed files with 82 additions and 106 deletions

1
.stylua.toml Normal file
View file

@ -0,0 +1 @@
indent_type = "Spaces"

View file

@ -22,6 +22,10 @@
shellcheck = {
enable = true;
};
stylua = {
enable = true;
};
};
};
};

View file

@ -1,4 +1,3 @@
lua << EOF
local wk = require("which-key")
local keys = {
@ -9,4 +8,3 @@ local keys = {
}
wk.register(keys, { prefix = "gc" })
EOF

View file

@ -1,4 +1,3 @@
lua << EOF
local wk = require("which-key")
local keys = {
@ -6,4 +5,3 @@ local keys = {
}
wk.register(keys, { prefix = "<leader>" })
EOF

View file

@ -1,4 +1,3 @@
lua << EOF
local wk = require("which-key")
local telescope_builtin = require("telescope.builtin")
@ -14,5 +13,3 @@ local keys = {
}
wk.register(keys, { prefix = "<leader>" })
EOF

View file

@ -1,4 +1,3 @@
lua << EOF
local wk = require("which-key")
local motions = {
@ -29,4 +28,3 @@ local objects = {
wk.register(motions, { mode = "n" })
wk.register(objects, { mode = "o" })
EOF

View file

@ -1,4 +1,3 @@
lua << EOF
local wk = require("which-key")
local keys = {
@ -31,7 +30,7 @@ local keys = {
x = "XML encode",
y = "C string encode",
-- Custom
d = { vim.diagnostic.goto_prev, "Previous diagnostic" }
d = { vim.diagnostic.goto_prev, "Previous diagnostic" },
},
["]"] = {
name = "Next",
@ -61,7 +60,7 @@ local keys = {
x = "XML decode",
y = "C string decode",
-- Custom
d = { vim.diagnostic.goto_next, "Next diagnostic" }
d = { vim.diagnostic.goto_next, "Next diagnostic" },
},
-- Option mappings
@ -125,4 +124,3 @@ local keys = {
}
wk.register(keys)
EOF

View file

@ -54,8 +54,6 @@ in
vim-beancount
vim-jsonnet
vim-nix
vim-pandoc
vim-pandoc-syntax
vim-toml
# General enhancements

View file

@ -39,7 +39,7 @@ M.on_attach = function(client, bufnr)
-- * nothing displayed
-- * single diagnostic at the end of the line (`virtual_text`)
-- * full diagnostics using virtual text (`virtual_lines`)
local text = vim.diagnostic.config().virtual_text
local text = vim.diagnostic.config().virtual_text
local lines = vim.diagnostic.config().virtual_lines
-- Text -> Lines transition
@ -63,7 +63,7 @@ M.on_attach = function(client, bufnr)
end
local function show_buffer_diagnostics()
vim.diagnostic.open_float(nil, { scope="buffer" })
vim.diagnostic.open_float(nil, { scope = "buffer" })
end
local keys = {
@ -94,5 +94,4 @@ M.on_attach = function(client, bufnr)
wk.register(keys, { buffer = bufnr })
end
return M

View file

@ -17,7 +17,9 @@ end
---@param cmd string? command to check
---@return fun(cmd: string): boolean executable
M.is_executable_condition = function(cmd)
return function() return M.is_executable(cmd) end
return function()
return M.is_executable(cmd)
end
end
-- whether or not we are currently in an SSH connection

View file

@ -0,0 +1,9 @@
local abbreviations = {
-- A few things that are hard to write in ASCII
["(R)"] = "©",
["(TM)"] = "",
}
for text, result in pairs(abbreviations) do
vim.cmd.abbreviate(text, result)
end

View file

@ -1,5 +0,0 @@
" A few useful sets of abbreviations
" A few things that are hard to write in ASCII
abbreviate (R) ©
abbreviate (TM)

View file

@ -0,0 +1,23 @@
-- Show lines numbers
vim.opt.number = true
local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", { clear = true })
-- Toggle numbers between relative and absolute when changing buffers
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
pattern = "*",
group = numbertoggle,
command = "if &nu | setlocal rnu | endif",
})
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
pattern = "*",
group = numbertoggle,
command = "if &nu | setlocal nornu | endif",
})
-- Never show the sign column in a terminal buffer
vim.api.nvim_create_autocmd({ "TermOpen" }, {
pattern = "*",
group = numbertoggle,
command = "setlocal nonu nornu",
})

View file

@ -1,13 +0,0 @@
" Idea for toggling taken from jeffkreeftmeijer
" Show line numbers
set number
augroup numbertoggle
autocmd!
" Toggle numbers between relative and absolute when changing buffers
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu | set rnu | endif
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
" Disable line numbers and relative line numbers in terminal
autocmd TermOpen * setlocal nonu nornu
augroup END

View file

@ -1,7 +1,6 @@
" Show completion menu in all cases, and don't select anything
set completeopt=menu,menuone,noselect
-- Show completion menu in all cases, and don't select anything
vim.opt.completeopt = { "menu", "menuone", "noselect" }
lua << EOF
local cmp = require("cmp")
local cmp_under_comparator = require("cmp-under-comparator")
local luasnip = require("luasnip")
@ -29,7 +28,7 @@ cmp.setup({
end,
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }),
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }),
["<C-d>"] = cmp.mapping.scroll_docs(-5),
["<C-d>"] = cmp.mapping.scroll_docs(-5),
["<C-f>"] = cmp.mapping.scroll_docs(5),
["<C-y>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
["<C-e>"] = cmp.mapping.abort(),
@ -61,4 +60,3 @@ cmp.setup({
ghost_text = true,
},
})
EOF

View file

@ -1,8 +1,6 @@
lua << EOF
local dressing = require("dressing")
dressing.setup({
-- Use a relative prompt size
prefer_width = 0.4,
})
EOF

View file

@ -0,0 +1,5 @@
-- Intercept all fold commands
-- stylua: ignore
vim.g.fastfold_fold_command_suffixes = {
"x", "X", "a", "A", "o", "O", "c", "C", "r", "R", "m", "M", "i", "n", "N",
}

View file

@ -1,5 +0,0 @@
" Intercept all fold commands
let g:fastfold_fold_command_suffixes=[
\ 'x', 'X', 'a', 'A', 'o', 'O', 'c', 'C',
\ 'r', 'R', 'm', 'M', 'i', 'n', 'N'
\ ]

View file

@ -1,5 +1,4 @@
lua << EOF
local gitsigns = require('gitsigns')
local gitsigns = require("gitsigns")
local wk = require("which-key")
gitsigns.setup({
@ -14,13 +13,13 @@ local keys = {
["[c"] = { "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", "Previous hunk/diff", expr = true },
["]c"] = { "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", "Next hunk/diff", expr = true },
-- Commands
["<leader>g"] = {
name = "Git",
-- Actions
b = { gitsigns.toggle_current_line_blame, "Toggle blame virtual text" },
d = { gitsigns.diffthis, "Diff buffer" },
-- stylua: ignore
D = { function() gitsigns.diffthis("~") end, "Diff buffer against last commit" },
g = { "<cmd>Git<CR>", "Git status" },
h = { gitsigns.toggle_deleted, "Show deleted hunks" },
@ -57,4 +56,3 @@ local visual = {
wk.register(keys, { buffer = bufnr })
wk.register(objects, { buffer = bufnr, mode = "o" })
wk.register(visual, { buffer = bufnr, mode = "x" })
EOF

View file

@ -1,4 +1,3 @@
lua << EOF
local lspconfig = require("lspconfig")
local lsp = require("ambroisie.lsp")
local utils = require("ambroisie.utils")
@ -44,4 +43,3 @@ if utils.is_executable("rust-analyzer") then
on_attach = lsp.on_attach,
})
end
EOF

View file

@ -1,4 +1,3 @@
lua << EOF
local lualine = require("lualine")
local utils = require("ambroisie.utils")
@ -60,4 +59,3 @@ lualine.setup({
"quickfix",
},
})
EOF

View file

@ -1,3 +1 @@
lua << EOF
require("luasnip.loaders.from_vscode").lazy_load()
EOF

View file

@ -1,4 +1,3 @@
lua << EOF
local null_ls = require("null-ls")
local lsp = require("ambroisie.lsp")
local utils = require("ambroisie.utils")
@ -66,7 +65,6 @@ null_ls.register({
}),
})
-- Shell (non-POSIX)
null_ls.register({
null_ls.builtins.code_actions.shellcheck.with({
@ -99,7 +97,7 @@ null_ls.register({
-- Shell (POSIX)
null_ls.register({
null_ls.builtins.code_actions.shellcheck.with({
-- Restrict to POSIX sh
-- Restrict to POSIX sh
filetypes = { "sh" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
@ -122,4 +120,3 @@ null_ls.register({
condition = utils.is_executable_condition("shfmt"),
}),
})
EOF

View file

@ -1,20 +0,0 @@
" Which code-block languages should I expect to be high-lighted.
let g:pandoc#syntax#codeblocks#embeds#langs=[
\ "bash=sh",
\ "c",
\ "cpp",
\ "go",
\ "haskell",
\ "python",
\ "rust",
\ "sh",
\ "vim",
\ "yaml",
\ "tex",
\ "toml",
\ "perl",
\ "json",
\ "latex=tex",
\ "make",
\ "makefile=make",
\ ]

View file

@ -3,15 +3,15 @@ if not require("ambroisie.utils").is_ssh() then
end
local function copy(lines, _)
require('osc52').copy(table.concat(lines, '\n'))
require("osc52").copy(table.concat(lines, "\n"))
end
local function paste()
return {vim.fn.split(vim.fn.getreg(''), '\n'), vim.fn.getregtype('')}
return { vim.fn.split(vim.fn.getreg(""), "\n"), vim.fn.getregtype("") }
end
vim.g.clipboard = {
name = 'osc52',
copy = {['+'] = copy, ['*'] = copy},
paste = {['+'] = paste, ['*'] = paste},
name = "osc52",
copy = { ["+"] = copy, ["*"] = copy },
paste = { ["+"] = paste, ["*"] = paste },
}

View file

@ -1,5 +1,3 @@
lua << EOF
require("nvim-surround").setup({
-- No configuration at the moment
})
EOF

View file

@ -1,4 +1,3 @@
lua << EOF
local telescope = require("telescope")
telescope.setup({
@ -8,8 +7,8 @@ telescope.setup({
["<C-h>"] = "which_key",
-- I want the normal readline mappings rather than scrolling
["<C-u>"] = false,
}
}
},
},
},
extensions = {
fzf = {
@ -23,4 +22,3 @@ telescope.setup({
telescope.load_extension("fzf")
telescope.load_extension("lsp_handlers")
EOF

View file

@ -1,4 +1,3 @@
lua << EOF
local ts_config = require("nvim-treesitter.configs")
ts_config.setup({
highlight = {
@ -55,4 +54,3 @@ ts_config.setup({
},
},
})
EOF

View file

@ -1,4 +1,2 @@
lua << EOF
local wk = require("which-key")
wk.setup()
EOF

View file

@ -0,0 +1,20 @@
local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true })
-- Only show sign column for the currently focused buffer
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, {
pattern = "*",
group = signtoggle,
command = "setlocal signcolumn=yes",
})
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, {
pattern = "*",
group = signtoggle,
command = "setlocal signcolumn=yes",
})
-- Never show the sign column in a terminal buffer
vim.api.nvim_create_autocmd({ "TermOpen" }, {
pattern = "*",
group = signtoggle,
command = "setlocal signcolumn=no",
})

View file

@ -1,8 +0,0 @@
augroup signtoggle
autocmd!
" Only show the sign column for the current focused buffer
autocmd BufEnter,FocusGained,WinEnter * set signcolumn=yes
autocmd BufLeave,FocusLost,WinLeave * set signcolumn=no
" Disable the sign column in terminal
autocmd TermOpen * setlocal signcolumn=no
augroup END