diff --git a/.config/nvim/lua/plugins/avante.lua b/.config/nvim/lua/plugins/avante.lua deleted file mode 100644 index 27ff7cb..0000000 --- a/.config/nvim/lua/plugins/avante.lua +++ /dev/null @@ -1,56 +0,0 @@ -return { - "yetone/avante.nvim", - event = "VeryLazy", - version = false, - enabled = false, - keys = { - "A", - "AvanteToggle" - }, - opts = { - behaviour = { - auto_suggestions = false, -- Experimental stage - auto_set_highlight_group = true, - auto_set_keymaps = false, - auto_apply_diff_after_generation = false, - support_paste_from_clipboard = false, - minimize_diff = true, -- Whether to remove unchanged lines when applying a code block - enable_token_counting = true, -- Whether to enable token counting. Default to true. - }, - }, - build = "make", - dependencies = { - "nvim-treesitter/nvim-treesitter", - "stevearc/dressing.nvim", - "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim", - "echasnovski/mini.pick", - "nvim-telescope/telescope.nvim", - "nvim-tree/nvim-web-devicons", - { - -- support for image pasting - "HakonHarnes/img-clip.nvim", - event = "VeryLazy", - opts = { - -- recommended settings - default = { - embed_image_as_base64 = false, - prompt_for_file_name = false, - drag_and_drop = { - insert_mode = true, - }, - -- required for Windows users - use_absolute_path = true, - }, - }, - }, - -- { - -- -- Make sure to set this up properly if you have lazy=true - -- 'MeanderingProgrammer/render-markdown.nvim', - -- opts = { - -- file_types = { "markdown", "Avante" }, - -- }, - -- ft = { "markdown", "Avante" }, - -- }, - }, -} diff --git a/.config/nvim/lua/plugins/commentless.lua b/.config/nvim/lua/plugins/commentless.lua deleted file mode 100644 index cbd011a..0000000 --- a/.config/nvim/lua/plugins/commentless.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - "soemre/commentless.nvim", - cmd = "Commentless", - keys = { - { - "/", - function() - require("commentless").toggle() - end, - desc = "Toggle Comments", - }, - }, - dependencies = { - "nvim-treesitter/nvim-treesitter", - }, - opts = { - -- Customize Configuration - }, -} diff --git a/.config/nvim/lua/plugins/hardtime.lua b/.config/nvim/lua/plugins/hardtime.lua new file mode 100644 index 0000000..24082e0 --- /dev/null +++ b/.config/nvim/lua/plugins/hardtime.lua @@ -0,0 +1,9 @@ +return { + "m4xshen/hardtime.nvim", + lazy = false, + dependencies = { + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + }, + opts = {}, +} diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua deleted file mode 100644 index bde744a..0000000 --- a/.config/nvim/lua/plugins/init.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - "nvim-lua/plenary.nvim", - event = "VeryLazy", - }, - { - "ray-x/guihua.lua", - event = "VeryLazy", - }, -} diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 67c4c4a..e25761f 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -161,17 +161,6 @@ return { end, }, - -- volar = { - -- filetypes = { - -- "javascript", - -- "typescript", - -- "vue", - -- }, - -- on_new_config = function(new_config, new_root_dir) - -- new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) - -- end, - -- }, - cssls = {}, intelephense = { @@ -252,6 +241,8 @@ return { }, }, }, + + clangd = {}, } require("mason").setup() diff --git a/.config/nvim/lua/plugins/neotest.lua b/.config/nvim/lua/plugins/neotest.lua index 39e5ee3..5d78b32 100644 --- a/.config/nvim/lua/plugins/neotest.lua +++ b/.config/nvim/lua/plugins/neotest.lua @@ -40,17 +40,6 @@ return { neotest.summary.toggle() end, { desc = "Toggle neotest summary pane" }) - local neotest_ns = vim.api.nvim_create_namespace("neotest") - vim.diagnostic.config({ - virtual_text = { - format = function(diagnostic) - local message = - diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "") - return message - end, - }, - }, neotest_ns) - vim.env.PROJECT_ROOT = vim.fn.getcwd() .. "/backend/" vim.env.ENV_PATH = vim.fn.getcwd() .. "/backend/.env" diff --git a/.config/nvim/lua/plugins/notify.lua b/.config/nvim/lua/plugins/notify.lua new file mode 100644 index 0000000..2d31561 --- /dev/null +++ b/.config/nvim/lua/plugins/notify.lua @@ -0,0 +1,7 @@ +return { + "rcarriga/nvim-notify", + lazy = false, + config = function () + vim.notify = require("notify") + end +} diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 15e7300..0965bd3 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -126,6 +126,8 @@ if [ -f "$HOME/.config/zsh/.api-keys" ]; then source "$HOME/.config/zsh/.api-keys" fi +bindkey -s '^F' "$HOME/.local/bin/tmux-sessionizer\n" + export PATH=~/.config/composer/vendor/bin:$PATH export PATH="/opt/flutter/bin:$PATH" diff --git a/.local/bin/open b/.local/bin/open new file mode 100755 index 0000000..1df3da2 --- /dev/null +++ b/.local/bin/open @@ -0,0 +1,317 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use constant +{ + PROG_EDIT => 'vim', +}; + +sub open_smart; +sub edit; +sub stdin_to_editor; +sub reveal; +sub header_edit; +sub wait_or_not; + +sub usage +{ + print STDERR <<"!"; +Usage: $0 -[efWwRh] +-e: edit +-f: stdin-edit +-W: wait for exit (true by default for editing) +-w: don't wait for exit +-R: reveal +-h: header search +! + exit 1; +} + +my $cmd = \&open_smart; +my(@files, @args); + +my %opts = ( + 'e' => 0, + 'f' => 0, + 'W' => 0, + 'R' => 0, + 'h' => 0, +); + +my $wait_set = 0; + +usage() unless @ARGV; + +for(my $i = 0; $i < @ARGV; ++$i){ + $_ = $ARGV[$i]; + + if($_ eq '--'){ + push @files, @ARGV[$i + 1 .. $#ARGV]; + last; + } + + if(/^-([a-z])$/i){ + my $k = $1; + + if(exists $opts{$k}){ + $opts{$k} = 1; + $wait_set = 1 if $k eq 'W'; + }elsif($k eq 'w'){ + $opts{W} = 0; + $wait_set = 1; + }else{ + usage(); + } + + }elsif($_ eq '--args'){ + push @args, @ARGV[$i + 1 .. $#ARGV]; + last; + + }elsif(/^-/){ + usage(); + + }else{ + push @files, $_; + + } +} + +if($opts{e} + $opts{f} + $opts{R} + $opts{h} > 1){ + print STDERR "Can't combine -e, -f, -R and -h\n"; + usage(); +} + +my $should_wait = 1; +if($opts{e}){ + $cmd = \&edit; + +}elsif($opts{f}){ + # | $EDITOR - + $cmd = \&stdin_to_editor; + +}elsif($opts{R}){ + # open with rox + $cmd = \&reveal; + $should_wait = 0; + +}elsif($opts{h}){ + # search /usr/include/$_ for @files + $cmd = \&header_edit; + +} + +$opts{W} = 1 if $should_wait and not $wait_set; + +exit(&{$cmd}(( + wait => !!$opts{W}, + args => [@args], + files => [@files]))); + +# end --- + +sub read_maps +{ + my $rc = "$ENV{HOME}/.openrc"; + open F, '<', $rc or die "open $rc: $!\n"; + + my %maps; + my $prog_reveal = ''; + + my $mode = 0; + while(){ + chomp; + s/#.*//; + + if(/^\[(.*)\]$/){ + if($1 eq 'full'){ + $mode = $1; + }elsif($1 eq 'suffix'){ + $mode = $1; + }elsif($1 eq 'directories'){ + $mode = $1; + }else{ + die "invalid section \"$1\" in $rc\n"; + } + + }elsif(!($mode eq 'directories') and my($prog, $matches) = /^([^:]+): *(.*)/){ + sub getenv + { + my $k = shift; + return $ENV{$k} if $ENV{$k}; + my %backup = ( + "TERM" => "urxvt", + "VISUAL" => "vim", + ); + return $backup{$k} if $backup{$k}; + return "\$$k"; + } + + my @matches = split / *, */, $matches; + + $prog =~ s/\$([A-Z_]+)/getenv($1)/e; + + my $key = $prog; + if($mode eq 'suffix'){ + # compare file extensions case insensitively + $key = lc $key; + } + + push @{$maps{$key}}, [ $_, $mode ] for @matches; + + }elsif($mode eq 'directories' && length){ + if(length($prog_reveal)){ + die "already have dir program, in $rc\n"; + } + $prog_reveal = $_; + + }elsif(length){ + die "invalid confiuration line: \"$1\" in $rc\n"; + } + } + + if(!length($prog_reveal)){ + die "no directory program specified, in $rc\n"; + } + + close F; + + return $prog_reveal, \%maps; +} + +sub open_smart +{ + my $ec = 0; + my %h = @_; + + my @to_open; + + my ($prog_reveal, $maps) = read_maps(); + +file: + for my $fnam (@{$h{files}}){ + #print "maps:\n"; + + if(-d $fnam){ + push @to_open, [($h{wait}, $prog_reveal, @{$h{args}}, $fnam)]; + next file; + } + + (my $fnam_for_test = $fnam) =~ s/\.[a-zA-Z]+$/lc($&)/e; + + for my $prog (keys %$maps){ + #print " $_:\n"; + for(@{$maps->{$prog}}){ + my($reg, $mode) = ($_->[0], $_->[1]); + if($mode eq 'suffix'){ + $reg = "\\.$reg\$"; + } + #print " $reg\n" + + if($fnam_for_test =~ /$reg/){ + push @to_open, [($h{wait}, $prog, @{$h{args}}, $fnam)]; + next file; + } + } + } + + die "no program found for $fnam\n"; + } + + wait_or_not(@{$_}) for @to_open; + + return 0; +} + +sub wait_or_not +{ + my($wait, @rest) = @_; + my $pid = fork(); + + die "fork(): $!\n" unless defined $pid; + + if($pid == 0){ + if($rest[0] =~ / /){ + my $a = shift @rest; + unshift @rest, split / +/, $a; + } + + exec @rest; + die; + }else{ + # parent + if($wait){ + my $reaped = wait(); + my $ret = $?; + + die "wait(): $!\n" if $reaped == -1; + warn "unexpected dead child $reaped (expected $pid)\n" if $reaped != $pid; + + return $ret; + } + } +} + +sub edit +{ + my %h = @_; + my $e = $ENV{VISUAL} || $ENV{EDITOR} || PROG_EDIT; + return wait_or_not($h{wait}, $e, @{$h{args}}, @{$h{files}}); +} + +sub stdin_to_editor +{ + my $tmp = "/tmp/stdin_$$"; + + open F, '>', $tmp or die "open $tmp: $!\n"; + print F $_ while ; + close F; + + my %h = @_; + push @{$h{files}}, $tmp; + my $r = edit(%h); + unlink $tmp; + return $r; +} + +sub reveal +{ + my %h = @_; + my ($prog_reveal) = read_maps(); + return wait_or_not($h{wait}, $prog_reveal, @{$h{args}}, @{$h{files}}); +} + +sub header_edit +{ + my %h = @_; + my @files = @{$h{files}}; + @{$h{files}} = (); + + for my $name (@files){ + sub find_header + { + my @inc = ("", "arpa", "net", "sys"); + my $r = shift; + my @matches; + + for(my @tmp = @inc){ + push @inc, "x86_64-linux-gnu/$_"; + } + + for my $inc (@inc){ + $inc = "/usr/include/$inc"; + + opendir D, $inc or next; + push @matches, map { "$inc/$_" } grep /$r/, readdir D; + closedir D; + } + + return @matches; + } + + my @paths = find_header($name); + push @{$h{files}}, @paths if @paths; + } + + return edit(%h); +} diff --git a/.local/bin/xurls b/.local/bin/xurls new file mode 100755 index 0000000..bbc3ad1 --- /dev/null +++ b/.local/bin/xurls @@ -0,0 +1,116 @@ +#!/usr/bin/perl + +use warnings; + +$hostchars = '[a-z0-9-._+]'; +$pathchars = '[a-z0-9-._+#=?&:;%/!,~]'; + +sub scan($$$) +{ + my ($file, $lineno, $line) = @_; + + chomp $line; + + while($line =~ s! + ([a-z]+://)? + +# http:// + + $hostchars+\.[a-z]+ + +# www.tim.google.com - the [a-z].com is the main anchor for the whole regex - incase http:// is omitted +# note no trailing slash + + ($pathchars+/\?)* + +# check for the index.php? part + + ($pathchars+|\($pathchars+\))* + +# check for pathchars, or a set of nested parens + !!xoi){ # allow space + comments, compile once, strcasecmp + + my($p,$m,$e) = ($`,$&,$'); + + $e = '.' . $e if $m =~ s/\.$//; + + if($opt{fname} && $file){ + print "$col{red}$file$col{none}:"; + } + + if($opt{lineno}){ + print "$col{green}$lineno$col{none}: "; + }elsif($opt{fname} && $file){ + print ' '; + } + + if($opt{hl}){ + print "$p$col{brown}$m$col{none}$e\n"; + }else{ + print "$m\n"; + } + } +} + +sub usage(){ + $printme =<<"!"; +Usage: $0 -[Chn] [FILES...] + -h: highlight + -c: force colour on (for pipes) + -C: colour off (only makes sense with -h) + -n: show line number +! + print STDERR $printme; + exit 1; +} + + +%opt = ( + colour => 1, + lineno => 0, + fname => 0, + hl => 0 +); +%col = ( + brown => "\e[0;31m", # hl + red => "\e[0;35m", # fname + green => "\e[0;32m", # lineno + none => "\e[0;0m" +); + +for $arg (@ARGV){ + if($arg eq '-h'){ + $opt{hl} = 1; + }elsif($arg eq '-n'){ + $opt{lineno} = 1; + }elsif($arg eq '-C'){ + $opt{colour} = 0; + }elsif($arg eq '-c'){ + usage() if $opt{colour} == 0; + $opt{colour} = 2; # force on + }elsif($arg eq '--help'){ + usage(); + }else{ + push @files, $arg; + } +} + +usage() if $opt{hl} && !$opt{colour}; + +$opt{fname} = 1 if $#files > 0 || $opt{lineno}; +if(!$opt{colour} || ($opt{colour} == 1 && !-t STDOUT)){ + $col{$_} = '' for keys %col; +} + +$| = 1; + +if(@files){ + for my $f (@files){ + my $n = 1; + open F, '<', $f or warn "$f: $!\n"; + scan($f, $n++, $_) for ; + close F; + } +}else{ + scan(undef, $., $_) while ; +} diff --git a/.openrc b/.openrc new file mode 100644 index 0000000..5b8c9d4 --- /dev/null +++ b/.openrc @@ -0,0 +1,22 @@ +[full] +brave: ^https?://, www\., \.com, \.co\.uk, \.net +#in_terminal yplay.pl: ^(http://)?(www\.)?youtube\.com/watch\?v= +in_terminal $VISUAL: \.[^/]*rc$ + +[suffix] +soffice: odp, pptx?, docx? +#in_terminal $VISUAL: txt, c, cpp, nfo, pl, py, s, conf +in_terminal less: log +mplayer: mp3, wav, mp4, wmv +mupdf: pdf +firefox: html? +soffice: odt +mupdf: pdf +sxiv: png, jpg, jpeg, gif +viking: gpx +# openshot-qt: mp4 + +#xterm -e wget: http://.*.(tar|gz|bz2) - not called due to hash ordering + +[directories] +pcmanfm