diff --git a/.config/fish/functions/fish_user_key_bindings.fish b/.config/fish/functions/fish_user_key_bindings.fish index ff0d9f3..cb9f03e 100644 --- a/.config/fish/functions/fish_user_key_bindings.fish +++ b/.config/fish/functions/fish_user_key_bindings.fish @@ -1,3 +1,7 @@ function fish_user_key_bindings fzf_key_bindings end + +function fsize + sed -i "s/size:.*/size: $argv/" $HOME/.config/alacritty/alacritty.yml +end diff --git a/.tmux.conf b/.tmux.conf index fa9b85b..be04e79 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -58,7 +58,7 @@ set-window-option -g window-style fg=#aaaaaa,bg=terminal set-window-option -g window-active-style fg=terminal,bg=terminal set -g status-left '#[fg=green][ #H ][ ' -set -g status-right '#[fg=green]][ #[bright]#[fg=blue]%Y-%m-%d #[fg=white]%I:%M #[dim]#[fg=green]]' +set -g status-right '#[fg=green]][ #{pane_width}x#{pane_height} #[bright]#[fg=blue]%Y-%m-%d #[fg=white]%I:%M #[dim]#[fg=green]]' # Notifying if other windows has activities setw -g monitor-activity on diff --git a/.vim/nvim.lua b/.vim/nvim.lua index ed03b61..fb95890 100644 --- a/.vim/nvim.lua +++ b/.vim/nvim.lua @@ -1,7 +1,7 @@ -require('nvim-autopairs').setup{} +require('nvim-autopairs').setup {} -- nvim_lsp object -local nvim_lsp = require'lspconfig' +local nvim_lsp = require 'lspconfig' -- function to attach completion when setting up lsp local on_attach = function(client) @@ -18,20 +18,29 @@ rust_capabilities.textDocument.completion.completionItem.resolveSupport = { } -- Enable rust_analyzer -nvim_lsp.rust_analyzer.setup({ - on_attach=on_attach, - capabilities=rust_capabilities, +nvim_lsp.rust_analyzer.setup({ + on_attach = on_attach, + capabilities = rust_capabilities, }) -nvim_lsp.gopls.setup({ on_attach=on_attach }) -nvim_lsp.pyright.setup({ on_attach=on_attach }) -nvim_lsp.clangd.setup({ on_attach=on_attach }) +nvim_lsp.gopls.setup({ on_attach = on_attach }) +nvim_lsp.pyright.setup({ on_attach = on_attach }) +nvim_lsp.clangd.setup({ on_attach = on_attach }) +nvim_lsp.tsserver.setup { + cmd = { "/home/barak/.yarn/bin/typescript-language-server", "--stdio" } +} +nvim_lsp.vuels.setup { + cmd = { "/home/barak/.yarn/bin/vls" } +} + +nvim_lsp.svelte.setup { + cmd = { "/home/barak/.yarn/bin/svelteserver", "--stdio" } +} local runtime_path = vim.split(package.path, ';') table.insert(runtime_path, "lua/?.lua") table.insert(runtime_path, "lua/?/init.lua") - -require'lspconfig'.sumneko_lua.setup { +require 'lspconfig'.sumneko_lua.setup { settings = { Lua = { runtime = { @@ -42,7 +51,7 @@ require'lspconfig'.sumneko_lua.setup { }, diagnostics = { -- Get the language server to recognize the `vim` global - globals = {'vim'}, + globals = { 'vim' }, }, workspace = { -- Make the server aware of Neovim runtime files @@ -59,50 +68,52 @@ require'lspconfig'.sumneko_lua.setup { require('go').setup() function org_imports(wait_ms) - local params = vim.lsp.util.make_range_params() - params.context = {only = {"source.organizeImports"}} + local params = vim.lsp.util.make_range_params() - local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, wait_ms) - for _, res in pairs(result or {}) do - for _, r in pairs(res.result or {}) do - if r.edit then - vim.lsp.util.apply_workspace_edit(r.edit) - else - vim.lsp.buf.execute_command(r.command) - end - end - end + params.context = { only = { "source.organizeImports" } } + + local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, wait_ms) + + for _, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + vim.lsp.util.apply_workspace_edit(r.edit, "utf-8") + else + vim.lsp.buf.execute_command(r.command) + end + end + end end nvim_lsp.efm.setup { - init_options = {documentFormatting = true}, - settings = { - rootMarkers = {".git/"}, - languages = { - lua = { - { formatCommand = "lua-format -i", formatStdin = true } - }, - python = { - { formatCommand = 'black --quiet -', formatStdin = true } - }, - rust = { - { formatCommand = 'rustfmt', formatStdin = true } - } - } + init_options = { documentFormatting = true }, + settings = { + rootMarkers = { ".git/" }, + languages = { + lua = { + { formatCommand = "lua-format -i", formatStdin = true } + }, + python = { + { formatCommand = 'black --quiet -', formatStdin = true } + }, + rust = { + { formatCommand = 'rustfmt', formatStdin = true } + } } + } } -- Enable diagnostics vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = false, - signs = true, - update_in_insert = false, - } + virtual_text = false, + signs = true, + update_in_insert = false, +} ) -- Compe setup -require'compe'.setup { +require 'compe'.setup { enabled = true; autocomplete = true; debug = false; @@ -123,21 +134,21 @@ require'compe'.setup { } --signature_cfg = { - --hint_enable = true, - --hint_prefix = "% ", - --handler_opts = { - --border = "none" - --}, +--hint_enable = true, +--hint_prefix = "% ", +--handler_opts = { +--border = "none" +--}, --} --require'lsp_signature'.on_attach(signature_cfg) saga_cfg = { - code_action_prompt = { - enable = false, - sign = false, - virtual_text = false, - }, + code_action_prompt = { + enable = false, + sign = false, + virtual_text = false, + }, } -- require'lspsaga'.init_lsp_saga(saga_cfg) @@ -146,12 +157,12 @@ local t = function(str) end local check_back_space = function() - local col = vim.fn.col('.') - 1 - if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then - return true - else - return false - end + local col = vim.fn.col('.') - 1 + if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + return true + else + return false + end end -- Use (s-)tab to: @@ -174,49 +185,49 @@ _G.s_tab_complete = function() end end -vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", { expr = true }) +vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", { expr = true }) +vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", { expr = true }) +vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", { expr = true }) require('lspkind').init({ - -- disables text annotations - --with_text = false, - --with_text = true, + -- disables text annotations + --with_text = false, + --with_text = true, - -- defines how annotations are shown - -- default: symbol - -- options: 'text', 'text_symbol', 'symbol_text', 'symbol' - mode = 'symbol', + -- defines how annotations are shown + -- default: symbol + -- options: 'text', 'text_symbol', 'symbol_text', 'symbol' + mode = 'symbol', - -- default symbol map - -- can be either 'default' or 'codicons' - preset = 'default', + -- default symbol map + -- can be either 'default' or 'codicons' + preset = 'default', - -- override preset symbols - -- default: {} - --symbol_map = { - --Method = 'm', - --Function = 'f', - --Text = 'txt', - --Constructor = 'new', - --Variable = 'var', - --Class = 'cls', - --Interface = 'iface', - --Module = 'mod', - --Property = 'prop', - --Unit = 'unit', - --Value = 'val', - --Enum = 'enum', - --Keyword = 'kw', - --Snippet = 'sn', - --Color = 'color', - --File = 'file', - --Folder = 'fold', - --EnumMember = 'enum', - --Constant = 'const', - --Struct = 'struct', - --}, + -- override preset symbols + -- default: {} + --symbol_map = { + --Method = 'm', + --Function = 'f', + --Text = 'txt', + --Constructor = 'new', + --Variable = 'var', + --Class = 'cls', + --Interface = 'iface', + --Module = 'mod', + --Property = 'prop', + --Unit = 'unit', + --Value = 'val', + --Enum = 'enum', + --Keyword = 'kw', + --Snippet = 'sn', + --Color = 'color', + --File = 'file', + --Folder = 'fold', + --EnumMember = 'enum', + --Constant = 'const', + --Struct = 'struct', + --}, }) --require('rust-tools').setup({ @@ -225,27 +236,27 @@ require('lspkind').init({ require('trouble').setup { mode = "document_diagnostics", auto_close = true, - action_keys = { -- key mappings for actions in the trouble list - -- map to {} to remove a mapping, for example: - -- close = {}, - --close = "q", -- close the list - --cancel = "", -- cancel the preview and get back to your last window / buffer / cursor - --refresh = "r", -- manually refresh - jump = {"o", ""}, -- jump to the diagnostic or open / close folds - --open_split = { "" }, -- open buffer in new split - --open_vsplit = { "" }, -- open buffer in new vsplit - open_tab = { }, -- open buffer in new tab - jump_close = {""}, -- jump to the diagnostic and close the list - toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode - toggle_preview = "P", -- toggle auto_preview - hover = "K", -- opens a small popup with the full multiline message - preview = "p", -- preview the diagnostic location - close_folds = {"zM", "zm"}, -- close all folds - open_folds = {"zR", "zr"}, -- open all folds - toggle_fold = {"zA", "za"}, -- toggle fold of current file - previous = "k", -- previous item - next = "j" -- next item - }, + action_keys = { -- key mappings for actions in the trouble list + -- map to {} to remove a mapping, for example: + -- close = {}, + --close = "q", -- close the list + --cancel = "", -- cancel the preview and get back to your last window / buffer / cursor + --refresh = "r", -- manually refresh + jump = { "o", "" }, -- jump to the diagnostic or open / close folds + --open_split = { "" }, -- open buffer in new split + --open_vsplit = { "" }, -- open buffer in new vsplit + open_tab = {}, -- open buffer in new tab + jump_close = { "" }, -- jump to the diagnostic and close the list + toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode + toggle_preview = "P", -- toggle auto_preview + hover = "K", -- opens a small popup with the full multiline message + preview = "p", -- preview the diagnostic location + close_folds = { "zM", "zm" }, -- close all folds + open_folds = { "zR", "zr" }, -- open all folds + toggle_fold = { "zA", "za" }, -- toggle fold of current file + previous = "k", -- previous item + next = "j" -- next item + }, } local trouble_telescope = require("trouble.providers.telescope") @@ -284,23 +295,23 @@ require('telescope').setup { }, } -local builtin = require'telescope.builtin' +local builtin = require 'telescope.builtin' -local dropdown = require'telescope.themes'.get_dropdown({ +local dropdown = require 'telescope.themes'.get_dropdown({ --previewer = false, --prompt_title = "", --results_height = 16, --width = 0.6, --borderchars = { - --{"─", "│", "─", "│", "╭", "╮", "╯", "╰"}, - --prompt = {"─", "│", " ", "│", "╭", "╮", "│", "│"}, - --results = {"─", "│", "─", "│", "├", "┤", "╯", "╰"}, - --preview = {"─", "│", "─", "│", "╭", "╮", "╯", "╰"} + --{"─", "│", "─", "│", "╭", "╮", "╯", "╰"}, + --prompt = {"─", "│", " ", "│", "╭", "╮", "│", "│"}, + --results = {"─", "│", "─", "│", "├", "┤", "╯", "╰"}, + --preview = {"─", "│", "─", "│", "╭", "╮", "╯", "╰"} --}, --winblend = 10 }) -local telescope_ivy = require'telescope.themes'.get_ivy({ +local telescope_ivy = require 'telescope.themes'.get_ivy({ }) @@ -309,7 +320,7 @@ local telescope_ivy = require'telescope.themes'.get_ivy({ -- Treesitter -- -require'nvim-treesitter.configs'.setup { +require 'nvim-treesitter.configs'.setup { -- One of "all", "maintained" (parsers with maintainers), or a list of languages ensure_installed = { "c", @@ -375,13 +386,13 @@ require'nvim-treesitter.configs'.setup { } } -require"nvim-treesitter.highlight".set_custom_captures { +require "nvim-treesitter.highlight".set_custom_captures { -- Highlight the @foo.bar capture group with the "Identifier" highlight group. -- ["foo.bar"] = "Identifier", ["generic_type_param"] = "TSCGenericTypeParam", } -require"neogen".setup {} +require "neogen".setup {} -- -- Helper functions for my own grepping commands. @@ -392,9 +403,9 @@ live_grep_repo = function(conf) local opt = telescope_ivy opt['cwd'] = vim.fn.systemlist("git rev-parse --show-toplevel")[1] --local opt = { - --cwd = vim.fn.systemlist("git rev-parse --show-toplevel")[1] + --cwd = vim.fn.systemlist("git rev-parse --show-toplevel")[1] --} - for k,v in pairs(conf) do opt[k] = v end + for k, v in pairs(conf) do opt[k] = v end builtin.live_grep(opt) end @@ -403,21 +414,21 @@ git_grep_word = function(conf) local opt = telescope_ivy opt['cwd'] = vim.fn.systemlist("git rev-parse --show-toplevel")[1] --local opt = { - --cwd = vim.fn.systemlist("git rev-parse --show-toplevel")[1] + --cwd = vim.fn.systemlist("git rev-parse --show-toplevel")[1] --} - for k,v in pairs(conf) do opt[k] = v end + for k, v in pairs(conf) do opt[k] = v end builtin.grep_string(opt) end buffer_telescope = function(conf) local opt = telescope_ivy - for k,v in pairs(conf) do opt[k] = v end + for k, v in pairs(conf) do opt[k] = v end builtin.buffers(opt) end file_list = function(conf) local opt = telescope_ivy - for k,v in pairs(conf) do opt[k] = v end + for k, v in pairs(conf) do opt[k] = v end builtin.git_files(opt) end @@ -426,15 +437,15 @@ end --- My own "where" clause generator for Rust --- function string.insert(str1, str2, pos) - return str1:sub(1,pos)..str2..str1:sub(pos+1) + return str1:sub(1, pos) .. str2 .. str1:sub(pos + 1) end function string.split(s, delimiter) - result = {}; - for match in (s..delimiter):gmatch("(.-)"..delimiter) do - table.insert(result, match); - end - return result; + result = {}; + for match in (s .. delimiter):gmatch("(.-)" .. delimiter) do + table.insert(result, match); + end + return result; end local function rust_whereify_line(line, var_name) @@ -457,13 +468,14 @@ local function rust_whereify_line(line, var_name) local whitespace = string.match(line, "^(%s*)") - local generic = "<"..var_name..">" + local generic = "<" .. var_name .. ">" local out = string.insert(line, generic, paren - 1) local brace = string.find(out, "%{") if brace == nil then brace = string.len(out) end - out = string.insert(out, "\n"..whitespace.."where\n"..whitespace.." "..var_name..": ,\n"..whitespace, brace - 1) + out = string.insert(out, "\n" .. whitespace .. "where\n" .. whitespace .. " " .. var_name .. ": ,\n" .. whitespace, + brace - 1) return string.split(out, "\n") end @@ -472,8 +484,8 @@ function rust_where_at_line() local var_name = vim.fn.input("Variable: ") local lineNum, col = unpack(vim.api.nvim_win_get_cursor(0)) local replacements = rust_whereify_line(vim.api.nvim_get_current_line(), var_name) - vim.api.nvim_buf_set_lines(0, lineNum-1, lineNum, false, replacements) - vim.api.nvim_win_set_cursor(0, {lineNum + 2, 4}) + vim.api.nvim_buf_set_lines(0, lineNum - 1, lineNum, false, replacements) + vim.api.nvim_win_set_cursor(0, { lineNum + 2, 4 }) end function neogen_dwim() @@ -484,17 +496,17 @@ function neogen_dwim() ["function_signature_item"] = "func", ["struct_item"] = "class", ["trait_item"] = "class", - ["package_clause"] = "type", - ["const_declaration"] = "type", + ["package_clause"] = "type", + ["const_declaration"] = "type", ["var_declaration"] = "type", ["class_definition"] = "class", } - local ts_utils = require'nvim-treesitter.ts_utils' + local ts_utils = require 'nvim-treesitter.ts_utils' local current_node = ts_utils.get_node_at_cursor() while (current_node) do local v = table[current_node:type()] - if v then + if v then require('neogen').generate({ type = v }) break else diff --git a/.vimrc b/.vimrc index eb8a754..1bb6605 100644 --- a/.vimrc +++ b/.vimrc @@ -171,7 +171,7 @@ Plug 'plytophogy/vim-virtualenv' Plug 'lunaru/vim-less' Plug 'hylang/vim-hy', {'for': 'hy'} "Plug 'mhartington/nvim-typescript' -Plug 'leafgarland/typescript-vim' +"Plug 'leafgarland/typescript-vim' Plug 'leafOfTree/vim-svelte-plugin' "Plug 'posva/vim-vue' Plug 'Shougo/context_filetype.vim' @@ -275,7 +275,7 @@ nnoremap gW lua vim.lsp.buf.workspace_symbol() "nnoremap gd lua vim.lsp.buf.declaration() nnoremap ga lua vim.lsp.buf.code_action() "nnoremap ga lua require('telescope.builtin').lsp_code_actions({initial_mode = "normal"}) -vnoremap ga lua vim.lsp.buf.range_code_actions() +vnoremap ga lua vim.lsp.buf.range_code_action() "vnoremap ga :lua require('telescope.builtin').lsp_range_code_actions({initial_mode = "normal"}) "nnoremap ge lua vim.lsp.diagnostic.show_line_diagnostics({show_header = false, focusable = false}) "nnoremap ge lua vim.diagnostic.open_float({focusable = false}) @@ -296,7 +296,7 @@ autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 1000) autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 1000) autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_seq_sync(nil, 1000) autocmd BufWritePre *.go lua vim.lsp.buf.formatting_seq_sync(nil, 1000) -autocmd BufWritePre *.go :silent! lua org_imports(3000) +autocmd BufWritePre *.go silent! lua org_imports(3000) " Goto previous/next diagnostic warning/error nnoremap g[ lua vim.diagnostic.goto_prev() diff --git a/bin/unborkify b/bin/unborkify index 120f56d..111940a 100755 --- a/bin/unborkify +++ b/bin/unborkify @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl use Getopt::Std; getopts('u');