Compare commits

...

5 Commits

Author SHA1 Message Date
fd6d93d0cf Improve backup script
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
2024-03-06 19:59:17 +01:00
6a82a8638d Improve editor config 2024-03-06 19:58:59 +01:00
993c40225e Fix backup-home service 2024-03-06 15:16:40 +01:00
db4cdfa886 Fix missing pkg for notify-send 2024-03-06 15:02:39 +01:00
47e70d7386 Add requests to python 2024-03-06 14:02:01 +01:00
4 changed files with 48 additions and 9 deletions

View File

@ -21,6 +21,11 @@ vim.keymap.set('n', '<leader>ff', require('telescope.builtin').find_files,
vim.keymap.set('n', '<leader>fg', require('telescope.builtin').live_grep,
{ desc = '[F]ind by [G]rep' })
-- Tabs
vim.keymap.set('n', '<leader>tt', ':tabnew<cr>')
vim.keymap.set('n', '<leader>tn', ':tabnext<cr>')
vim.keymap.set('n', '<leader>tp', ':tabprevious<cr>')
-- LSP
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition)

View File

@ -20,7 +20,7 @@ lsp_zero.format_on_save({
['tsserver'] = { 'typescript', 'javascript' },
},
})
-- LSP: go
local lspconfig = require('lspconfig')
lspconfig.gopls.setup({
settings = {
@ -33,7 +33,30 @@ lspconfig.gopls.setup({
}
}
})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
local params = vim.lsp.util.make_range_params()
params.context = { only = { "source.organizeImports" } }
-- buf_request_sync defaults to a 1000ms timeout. Depending on your
-- machine and codebase, you may want longer. Add an additional
-- argument after params if you find that you have to write the file
-- twice for changes to be saved.
-- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000)
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params)
for cid, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16"
vim.lsp.util.apply_workspace_edit(r.edit, enc)
end
end
end
vim.lsp.buf.format({ async = false })
end
})
-- LSP: nix
lspconfig.nil_ls.setup({
autostart = true,
settings = {
@ -45,6 +68,7 @@ lspconfig.nil_ls.setup({
},
})
-- LSP: lua
lspconfig.lua_ls.setup({
on_init = function(client)
local path = client.workspace_folders[1].name
@ -85,6 +109,7 @@ lspconfig.lua_ls.setup({
}
})
-- LSP: ts/js
lspconfig.tsserver.setup({
init_options = {
plugins = {
@ -206,9 +231,10 @@ cmp.setup({
}),
sources = cmp.config.sources({
}, {
{ name = "copilot", group_index = 2 },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "copilot", group_index = 2 },
{ name = "nvim_lsp", group_index = 2 },
-- { name = "luasnip" },
-- { name = "buffer" },
})
})

View File

@ -56,7 +56,9 @@
typescript
# Py stuff
python3
(unstable.python312.withPackages (p: with p; [
requests
]))
poetry
ruff

View File

@ -11,7 +11,6 @@ let
retval=$?
if [ $retval -ne 0 ]; then
echo "Failed to send notification"
exit 1
fi
# Do the backup
@ -19,11 +18,18 @@ let
${pkgs.restic}/bin/restic backup /home/torjus \
--exclude '/home/torjus/.cache' \
--exclude '/home/torjus/.local/share/Steam' \
--exclude '/home/torjus/.local/share/containers' \
--exclude '/home/torjus/git/nixpkgs'
retval=$?
if [ $retval -ne 0 ]; then
notify-send -u critical "Backup failed" "Backup of /home/torjus failed"
exit 1
${pkgs.libnotify}/bin/notify-send -u critical "Backup failed" "Backup of /home/torjus failed"
retval=$?
if [ $retval -ne 0 ]; then
# TODO: put token in sops
${pkgs.curl}/bin/curl "https://gotify.t-juice.club/message?token=ABgV8XT62bxyCzF" \
-F "title=Backup of home@gunter failed!" \
-F "message=Please check status of backup-home service"
fi
fi
# Remove old snapshots and prune
@ -48,7 +54,7 @@ let
retval=$?
if [ $retval -ne 0 ]; then
echo "Failed to send notification"
exit 1
exit $retval
fi
'';
in