diff --git a/common/bin/tdf b/common/bin/tdf index 96d3cd2..e712a4a 100755 --- a/common/bin/tdf +++ b/common/bin/tdf @@ -1,2 +1,2 @@ -#!/usr/bin/env sh -tmux new-session -s dotfiles -c "$DOTFILES_PATH" +#!/usr/bin/env fish +tmux-lyte-session dotfiles $DOTFILES_PATH diff --git a/common/bin/tenv b/common/bin/tenv new file mode 100755 index 0000000..39fa9c8 --- /dev/null +++ b/common/bin/tenv @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +d="$(command ls $ENV_PATH | fzf)" +tmux-lyte-session "env-$d" "$ENV_PATH/$d" diff --git a/common/bin/tmux-lyte-session b/common/bin/tmux-lyte-session new file mode 100755 index 0000000..d3e67db --- /dev/null +++ b/common/bin/tmux-lyte-session @@ -0,0 +1,5 @@ +#!/usr/bin/env fish +set session_name $argv[1] +set dir (set -q $argv[2] && echo $argv2 || pwd) +tmux new-session -D -s $session_name -c $dir || \ + tmux attach-session -d -t $session_name diff --git a/common/neovim/.gitignore b/common/neovim/.gitignore index 1adac55..030b11f 100644 --- a/common/neovim/.gitignore +++ b/common/neovim/.gitignore @@ -2,6 +2,6 @@ !/.gitignore !/init.vim !/init.lua -!/nvim_lsp.lua !/ftplugin +!/lua !/coc-settings.json diff --git a/common/neovim/init.lua b/common/neovim/init.lua index 049454c..1dbaddc 100644 --- a/common/neovim/init.lua +++ b/common/neovim/init.lua @@ -228,6 +228,6 @@ require('telescope').setup{ } } -require('fold').setup() -require('statusline').setup() -require('lsp').setup() +require('./fold').setup() +require('./statusline').setup() +require('./lsp').setup() diff --git a/common/neovim/lua/fold.lua b/common/neovim/lua/fold.lua new file mode 100644 index 0000000..bd8bed5 --- /dev/null +++ b/common/neovim/lua/fold.lua @@ -0,0 +1,12 @@ +function NeatFoldText() + -- TODO: finish this! + -- local lines_count = vim.foldend - vim.foldstart + 1 + -- local foldchar = vim.fn.matchstr(vim.fillchars, 'fold:\\zs.') + -- local foldtextstart = vim.fn.strpart('^' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3) + -- let foldtextend = printf("%s %".(winwidth(0)-20)."dL", foldtextstart, getline(v:foldstart), lines_count) + -- let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn + -- return printf("%s%d", substitute(getline(v:foldstart), "^.", ">"), lines_count) +end +-- set foldtext=NeatFoldText() + +return {setup = function() end} diff --git a/common/neovim/lua/lsp.lua b/common/neovim/lua/lsp.lua new file mode 100644 index 0000000..a29f968 --- /dev/null +++ b/common/neovim/lua/lsp.lua @@ -0,0 +1,86 @@ +local opts = {noremap=true, silent=true} + +vim.api.nvim_set_keymap('n', '[g', '(coc-diagnostic-prev)', opts) +vim.api.nvim_set_keymap('n', ']g', '(coc-diagnostic-next)', opts) + +vim.api.nvim_set_keymap('n', 'gd', '(coc-definition)', opts) +vim.api.nvim_set_keymap('n', 'gy', '(coc-type-definition)', opts) + +local nvim_lsp = require('lspconfig') +local on_attach = function(_client, bufnr) + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + local kmaps = { + ['gD']='lua vim.lsp.buf.declaration()' + } + + for k,v in pairs(kmaps) do + vim.api.nvim_buf_set_keymap(bufnr, 'n', k, v, opts) + end + + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) +end + +local servers = {'clangd', 'rust_analyzer', 'pyright', 'tsserver'} +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup{on_attach=on_attach} +end + +local sumneko_root_path = vim.fn.getenv('HOME')..'/.local/bin/sumneko_lua' +local sumneko_binary_path = '/bin/linux/lua-language-server' +nvim_lsp.sumneko_lua.setup{ + cmd={sumneko_root_path .. sumneko_binary_path, '-E', sumneko_root_path..'/main.lua'}; + on_attach=on_attach, + settings={ + Lua={ + runtime={ + version='LuaJIT', + path=vim.split(package.path, ';'), + }, + diagnostics={ + globals={'vim'}, + }, + workspace={ + library={ + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + }, + }, + }, + }, +} + +vim.cmd "command! Format execute 'lua vim.lsp.buf.formatting()'" +vim.o.completeopt = 'menuone,noinsert' + +-- Compe setup +require'compe'.setup{ + enabled=true, + autocomplete=true, + debug=false, + min_length=1, + preselect='enable', + throttle_time=80, + source_timeout=200, + incomplete_delay=400, + max_abbr_width=100, + max_kind_width=100, + max_menu_width=100, + documentation=true, + source={path=true, nvim_lsp=true}, +} + +return { + setup=function() + end +} diff --git a/common/neovim/nvim_lsp.lua b/common/neovim/lua/nvim_lsp.lua similarity index 100% rename from common/neovim/nvim_lsp.lua rename to common/neovim/lua/nvim_lsp.lua diff --git a/common/neovim/lua/statusline.lua b/common/neovim/lua/statusline.lua new file mode 100644 index 0000000..c8b34e5 --- /dev/null +++ b/common/neovim/lua/statusline.lua @@ -0,0 +1,72 @@ +-- TODO: make override-able +vim.g.status_line_max_length = 5 + +-- TODO: only update this portion when needed instead of every render? + +function StatusLineBufferByNum(bufnum) + local bufinfo = vim.fn.getbufinfo(bufnum) + local prefix = ' %#InactiveBuffer#' + local suffix = '%* ' + + if bufinfo.changed then + prefix = '%#DirtyBuffer# ' + suffix = ' %*' + end + + if bufinfo.hidden == 0 and vim.fn.index(bufinfo.windows, vim.g.statusline_winid) >= 0 then + prefix = '%#ActiveBuffer# ' + suffix = ' %*' + if bufinfo.changed then + prefix = '%#ActiveBuffer# *' + suffix = ' %*' + end + end + + return prefix..vim.fn.fnamemodify(vim.fn.bufname(bufnum), ':t')..suffix +end + +function StatusLineBuffers() + -- TODO: mark buffers with unsaved changes + + local active_index = -1 + local acc = {} + for _,bufnum in ipairs(vim.api.nvim_list_bufs()) do + local bufinfo = vim.fn.getbufinfo(bufnum) + if bufinfo.listed ~= 0 then + local entry = StatusLineBufferByNum(bufnum) + table.insert(acc, entry) + if vim.fn.matchstr(entry, '^%#ActiveBuffer#') then + active_index = vim.fn.index(acc, entry) + end + end + end + if active_index >= 0 then + -- TODO: instead implement this as a wraparound carousel? + local offset = vim.g.status_line_max_length / 2 + local min_buf_num = math.max(0, (active_index - offset)) + local max_buf_num = math.min(#acc - 1, min_buf_num + vim.g.status_line_max_length - 1) + min_buf_num = math.max(0, max_buf_num - vim.g.status_line_max_length + 1) + local buflist = table.concat({unpack(acc, min_buf_num, max_buf_num)}, '') + local prefix = '' + local suffix = '' + if min_buf_num > 0 then + prefix = '< ' + end + if max_buf_num < (#acc - 1) then + suffix = ' >' + end + return prefix..buflist..suffix + else + return table.concat(acc, '') + end +end + +function StatusLine() + return StatusLineBuffers()..'%*%=%c,%l/%L (%p%%)' +end + +return { + setup=function() + vim.o.statusline = ''..StatusLine() + end +} diff --git a/os/linux/kanshi/config b/os/linux/kanshi/config index e6093d2..85117a8 100644 --- a/os/linux/kanshi/config +++ b/os/linux/kanshi/config @@ -32,6 +32,12 @@ profile desktop-ultrawide { exec "$HOME/.config/lytedev-dotfiles/apps/de/kanshi/desktop-single-workspace.sh" } +profile laptop-with-display { + output "Sharp Corporation 0x144A 0x00000000" enable mode 1920x1080@60Hz position 0,0 scale 1 transform normal + output DP-1 enable mode 1920x1080@60Hz position 0,0 scale 1 transform normal + exec "$HOME/.config/lytedev-dotfiles/apps/de/kanshi/laptop-single-workspace.bash" +} + profile laptop { output "Sharp Corporation 0x144A 0x00000000" enable mode 3200x1800@60Hz position 0,0 scale 2 transform normal } diff --git a/os/linux/kanshi/desktop-single-workspace.sh b/os/linux/kanshi/desktop-single-workspace.sh index 69b1fdc..6c14e03 100644 --- a/os/linux/kanshi/desktop-single-workspace.sh +++ b/os/linux/kanshi/desktop-single-workspace.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash move_workspace() { swaymsg workspace "$1"; swaymsg move workspace to "'$2'"; } diff --git a/os/linux/kanshi/laptop-single-workspace.bash b/os/linux/kanshi/laptop-single-workspace.bash new file mode 100644 index 0000000..10c6239 --- /dev/null +++ b/os/linux/kanshi/laptop-single-workspace.bash @@ -0,0 +1,6 @@ + +#!/usr/bin/env bash + +move_workspace() { swaymsg workspace "$1"; swaymsg move workspace to "'$2'"; } +setup_output() { out="$1"; shift; while (($#)); do move_workspace "$1" "$out"; shift; done; } +setup_output eDP-1 1 2 3 4 5 6 7 8 9