1
0
Fork 0

lots of configuration work

This commit is contained in:
Luca Bilke 2024-04-12 18:49:52 +02:00
parent abea5cdae6
commit 1a228b6827
10 changed files with 100 additions and 87 deletions

View File

@ -1,3 +1,4 @@
map gh cd /home/luca
map gch cd /home/luca/.cache
map gcf cd /home/luca/.config

View File

@ -14,7 +14,10 @@ vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{
"LazyVim/LazyVim",
import = "lazyvim.plugins"
},
{ import = "lazyvim.plugins.extras.coding.yanky" },
{ import = "lazyvim.plugins.extras.coding.copilot" },
{ import = "lazyvim.plugins.extras.dap.core" },
@ -25,7 +28,7 @@ require("lazy").setup({
{ import = "plugins" },
},
defaults = {
lazy = false,
lazy = true,
version = false,
},
install = { colorscheme = { "tokyonight" } },

View File

@ -3,7 +3,13 @@
-- Add any additional options here
local o = vim.opt
local g = vim.g
o.shiftwidth = 4
o.tabstop = 4
o.scrolloff = 8
g.loaded_node_provider = 0
g.loaded_perl_provider = 0
g.loaded_python3_provider = 0
g.loaded_ruby_provider = 0

View File

@ -28,6 +28,7 @@ M.mason_install = {
"ansible-lint",
"ansible-language-server",
"basedpyright",
"bash-language-server",
"codelldb",
"dockerfile-language-server",
"docker-compose-language-service",
@ -37,6 +38,7 @@ M.mason_install = {
"marksman",
"markdownlint",
"ruff-lsp",
"rust-analyzer"
}
---@type Array<string>

View File

@ -37,49 +37,60 @@ return {
"hrsh7th/nvim-cmp",
opts = function(_, opts)
local cmp = require("cmp")
local function has_words_before()
local line, col = (unpack or table.unpack)(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
-- stylua: ignore
local luasnip = require("luasnip")
table.insert(opts.auto_brackets, "python")
table.insert(opts.sources, { name = "crates" })
opts.mapping = vim.tbl_deep_extend("force", opts.mapping, {
["<up>"] = require("cmp").mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
["<Down>"] = require("cmp").mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
["<C-p>"] = require("cmp").mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-n>"] = require("cmp").mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-k>"] = require("cmp").mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-j>"] = require("cmp").mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-u>"] = require("cmp").mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
["<C-d>"] = require("cmp").mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
["<C-Space>"] = cmp.mapping.confirm({ select = false }),
["<C-y>"] = cmp.config.disable,
["<C-e>"] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close() }),
["<CR>"] = vim.NIL,
opts.preselect = cmp.PreselectMode.None
opts.snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
}
opts.mapping = {
['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
-- TODO: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#confirm-candidate-on-tab-immediately-when-theres-only-one-completion-entry
['<C-Space>'] = cmp.mapping(function(fallback)
if cmp.visible() then
if luasnip.expandable() then
luasnip.expand()
else
cmp.confirm({
select = true,
})
end
else
fallback()
end
end),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_locally_jumpable() then
require("luasnip").expand_or_jump()
elseif has_words_before() then
cmp.complete()
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
})
}
opts.experimental = {
ghost_text = false,
}
end,
},
{
@ -135,7 +146,7 @@ return {
-- stylua: ignore
keys = {
{ "<leader>dPt", function() require("dap-python").test_method() end, desc = "Debug Method", ft = "python" },
{ "<leader>dPc", function() require("dap-python").test_class() end, desc = "Debug Class", ft = "python" },
{ "<leader>dPc", function() require("dap-python").test_class() end, desc = "Debug Class", ft = "python" },
},
config = function()
local path = require("mason-registry").get_package("debugpy"):get_install_path()

View File

@ -3,9 +3,9 @@ return {
"folke/tokyonight.nvim",
lazy = true,
opts = { style = "night" },
-- on_highlights = function(hl, _)
-- hl.CurSearch = nil
-- end
on_highlights = function(hl, _)
hl.CurSearch = nil
end
},
{
"folke/noice.nvim",
@ -46,4 +46,31 @@ return {
},
},
},
{
"nvim-lualine/lualine.nvim",
opts = {
sections = {
lualine_y = {
{
function()
local chars = { "", "", "", "", "", "", "", "", "", "", "", "", "" }
return chars[math.ceil(vim.fn.line "." / vim.fn.line "$" * #chars)]
end,
separator = " ",
padding = { left = 1, right = 0 },
},
{ "location", padding = { left = 0, right = 1 } },
},
lualine_z = {
{
"o:encoding",
fmt = string.upper,
separator = " ",
padding = { left = 1, right = 0 },
},
{ "fileformat", padding = { left = 0, right = 1 } },
},
}
}
}
}

View File

@ -9,8 +9,8 @@ map D navigate next
map P toggle_page_mode
map r reload
map R rotate
map K zoom in
map J zoom out
map K page-up
map J page-down
map i recolor
map p print
map g goto top

View File

@ -125,9 +125,11 @@ localpath="$(find -L ~/.local/bin -type d -printf %p: | sed 's/.$//')"
fpath=($XDG_CONFIG_HOME/zsh/completions $fpath)
export PATH="$PATH:$localpath"
# export NVM_DIR="$HOME/.config/nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PNPM_HOME="/home/luca/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then

View File

@ -1,3 +1,4 @@
hash -d h=/home/luca
hash -d ch=/home/luca/.cache
hash -d cf=/home/luca/.config

View File

@ -1,66 +1,26 @@
#!/bin/sh
# Inputs
bmdirs="$XDG_CONFIG_HOME/directories"
# Outputs
zsh_named_dirs="$ZDOTDIR/configs/hashes"
# lf_dirs="$XDG_DATA_HOME/lf/shortcuts"
lf_maps="$XDG_CONFIG_HOME/lf/shortcuts"
# TODO: Finish this function LOL
# find_marker() {
# file=$1
# for marker in \
# "# @SHORTCUTS@" \
# "-- @SHORTCUTS@" \
# "// @SHORTCUTS@" \
# "/* @SHORTCUTS@ */"; do
# file=$(grep -xn "$marker" "$file")
# if [ -n "$file" ]; then
# echo "$file"
# return
# fi
# done
# }
zsh() {
xargs printf "hash -d %s=%s\n"
}
clean() {
rm -rf "/tmp/shortcuts"
echo >"$ZDOTDIR/configs/hashes"
echo >"$XDG_CONFIG_HOME/lf/shortcuts"
}
write_dirs_tmp() {
write() {
while IFS= read -r line; do
shortcut=$(echo "$line" | cut -d' ' -f1)
path=$(echo "$line" | cut -d' ' -f2)
path=$(eval "echo $path")
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"/tmp/shortcuts/zsh_named_dirs"
# printf "%s:%s\n" "$shortcut" "$path" >>"/tmp/shortcuts/lf_dirs"
printf "map g%s cd %s\n" "$shortcut" "$path" >>"/tmp/shortcuts/lf_maps"
printf "hash -d %s=%s\n" "$shortcut" "$path" >>"$ZDOTDIR/configs/hashes"
printf "map g%s cd %s\n" "$shortcut" "$path" >>"$XDG_CONFIG_HOME/lf/shortcuts"
done
}
apply_tmp() {
cat /tmp/shortcuts/zsh_named_dirs >"$zsh_named_dirs"
# cat /tmp/shortcuts/lf_dirs >"$lf_dirs"
cat /tmp/shortcuts/lf_maps >"$lf_maps"
filter() {
input=$1
sed 's/#.*//;/^$/d;s/ \+/ /g' "$input"
}
read_file() {
in_file=$1
sed 's/#.*//;/^$/d' "$in_file" | tr -s ' '
}
trap clean EXIT
mkdir -p /tmp/shortcuts
read_file "$bmdirs" | write_dirs_tmp
apply_tmp
clean
filter "$XDG_CONFIG_HOME/directories" | write