From 3431afbe52aaaf9347d0bd3e9bb835793cdccb98 Mon Sep 17 00:00:00 2001 From: Zev Averbach Date: Tue, 2 Apr 2024 09:49:23 +0200 Subject: [PATCH] a bunch --- .eslintrc.json | 18 +++ .prettierrc.json | 6 + bash_aliases | 7 +- init.lua | 309 ++++++++++++++++++++++++++++++----------------- tmux.conf | 28 ++++- vimrc.vim | 41 +++++-- 6 files changed, 281 insertions(+), 128 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .prettierrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..2940231 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "env": { + "browser": true, + "es2021": true, + "node": true + }, + "extends": "standard-with-typescript", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "indent": ["error", 4], + "semi": ["error", "always"], + "quotes": ["error", "double"], + "comma-dangle": ["error", "only-multiline"] + } +} diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..d708abb --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "trailingComma": "es5", + "tabWidth": 4, + "semi": true, + "singleQuote": false +} diff --git a/bash_aliases b/bash_aliases index 92463d2..15788a7 100644 --- a/bash_aliases +++ b/bash_aliases @@ -8,12 +8,15 @@ alias vl='vi ~/.config/nvim/init.lua' alias vv='vi ~/.config/nvim/vimrc.vim' alias gb='git branch' alias gl='git log' -alias pp='vi ~/.profile' alias pg='git pull origin $(git branch --show-current)' alias gp='git push origin $(git branch --show-current)' alias gs='git status' alias gd='git diff' alias ga='git add --all' -alias l='ls -l' alias i='ipython' alias python=python3 +alias v="vagrant ssh" +alias tt='vi ~/.tmux.conf' +alias t='tree -a -I "*.pyc|*__pycache__|.git|.data|.pytest_cache|.ruff_cache"' +alias p3=python3 +alias l='ls -lrta' diff --git a/init.lua b/init.lua index 6c875d0..2a76d23 100644 --- a/init.lua +++ b/init.lua @@ -1,112 +1,197 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" - -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) -end - -vim.opt.rtp:prepend(lazypath) -vim.opt.colorcolumn = "120" -vim.opt.updatetime = 50 -- improve perf, less frequent swp writes -vim.opt.termguicolors = true -vim.opt.hlsearch = false -vim.opt.incsearch = true -vim.opt.smartindent = true -vim.opt.scrolloff = 8 -vim.opt.signcolumn = "yes" -vim.opt.isfname:append("@-@") - -require("lazy").setup({ - "github/copilot.vim", - "folke/tokyonight.nvim", - "tpope/vim-commentary", - { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = { - }, - }, - { - 'nvim-telescope/telescope.nvim', tag = '0.1.5', - dependencies = { 'nvim-lua/plenary.nvim', - 'BurntSushi/ripgrep'} - }, - {'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build'}, - {'VonHeikemen/lsp-zero.nvim', branch = 'v3.x'}, - {'neovim/nvim-lspconfig'}, - {'hrsh7th/cmp-nvim-lsp'}, - {'hrsh7th/nvim-cmp'}, - {"mfussenegger/nvim-jdtls"}, - {'L3MON4D3/LuaSnip'}, - {"neoclide/coc.nvim", branch = 'release'}, - { - "kylechui/nvim-surround", - version = "*", - event = "VeryLazy", - config = function() - require("nvim-surround").setup({ - }) - end - }, -}) -require('telescope').setup { - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = "smart_case", -- or "ignore_case" or "respect_case" - -- the default case_mode is "smart_case" - } - } -} -local vimrc = vim.fn.stdpath("config") .. "/vimrc.vim" -vim.cmd.source(vimrc) -local lsp_zero = require('lsp-zero') - -lsp_zero.on_attach(function(client, bufnr) - lsp_zero.default_keymaps({buffer = bufnr}) -end) -require('lspconfig').pyright.setup({ -virtual_text=false, -}) - -local config = { - cmd = { - -- - "/usr/bin/java", -- Or the absolute path '/path/to/java11_or_newer/bin/java' - "-Declipse.application=org.eclipse.jdt.ls.core.id1", - "-Dosgi.bundles.defaultStartLevel=4", - "-Declipse.product=org.eclipse.jdt.ls.core.product", - "-Dlog.protocol=true", - "-Dlog.level=ALL", - "-Xms1g", - "--add-modules=ALL-SYSTEM", - "--add-opens", - "java.base/java.util=ALL-UNNAMED", - "--add-opens", - "java.base/java.lang=ALL-UNNAMED", - -- - "-jar", - "/usr/local/Cellar/jdtls/1.32.0/libexec/plugins/org.eclipse.equinox.launcher_1.6.700.v20231214-2017.jar", - "-configuration", "/usr/local/Cellar/jdtls/1.32.0/libexec/config_mac", - "-data", "/Users/zev/.local/share/nvim/java" - }, - settings = { - java = { - signatureHelp = {enabled = true}, - import = {enabled = true}, - rename = {enabled = true} - } - }, - init_options = { - bundles = {} - } -} - +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end + +vim.opt.rtp:prepend(lazypath) +vim.opt.colorcolumn = "120" +vim.opt.updatetime = 50 -- improve perf, less frequent swp writes +vim.opt.termguicolors = true +vim.opt.hlsearch = false +vim.opt.incsearch = true +vim.opt.smartindent = true +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +require("lazy").setup({ + "folke/tokyonight.nvim", + "tpope/vim-commentary", + { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = {}, + }, + { + "nvim-telescope/telescope.nvim", + tag = "0.1.5", + dependencies = { "nvim-lua/plenary.nvim", "BurntSushi/ripgrep" }, + }, + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build", + }, + { "VonHeikemen/lsp-zero.nvim", branch = "v3.x" }, + { "neovim/nvim-lspconfig" }, + { "nvim-treesitter/nvim-treesitter" }, + { + "stevearc/conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + require("conform").setup({ + formatters_by_ft = { + lua = { "stylua" }, + svelte = { { "prettierd", "prettier" } }, + javascript = { { "prettierd", "prettier" } }, + typescript = { { "prettierd", "prettier" } }, + javascriptreact = { { "prettierd", "prettier" } }, + typescriptreact = { { "prettierd", "prettier" } }, + json = { { "prettierd", "prettier" } }, + graphql = { { "prettierd", "prettier" } }, + java = { "google-java-format" }, + kotlin = { "ktlint" }, + ruby = { "standardrb" }, + markdown = { { "prettierd", "prettier" } }, + erb = { "htmlbeautifier" }, + html = { "htmlbeautifier" }, + bash = { "beautysh" }, + proto = { "buf" }, + rust = { "rustfmt" }, + yaml = { "yamlfix" }, + toml = { "taplo" }, + css = { { "prettierd", "prettier" } }, + scss = { { "prettierd", "prettier" } }, + }, + format_on_save = { + -- These options will be passed to conform.format() + timeout_ms = 500, + lsp_fallback = true, + }, + }) + end, + }, + { + "mfussenegger/nvim-lint", + event = { + "BufReadPre", + "BufNewFile", + }, + config = function() + local lint = require("lint") + + lint.linters_by_ft = { + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + javascriptreact = { "eslint_d" }, + typescriptreact = { "eslint_d" }, + svelte = { "eslint_d" }, + kotlin = { "ktlint" }, + terraform = { "tflint" }, + ruby = { "standardrb" }, + } + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set("n", "ll", function() + lint.try_lint() + end, { desc = "Trigger linting for current file" }) + end, + }, + { "hrsh7th/nvim-cmp" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/vim-vsnip" }, + { "L3MON4D3/LuaSnip" }, + { 'czheo/mojo.vim' }, + { "neoclide/coc.nvim", branch = "release" }, + { + "kylechui/nvim-surround", + version = "*", + event = "VeryLazy", + config = function() + require("nvim-surround").setup({}) + end, + }, +}) +require("telescope").setup({ + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + }, + }, +}) +local vimrc = vim.fn.stdpath("config") .. "/vimrc.vim" +vim.cmd.source(vimrc) + +local cmp = require("cmp") +cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + + mapping = { + ["C-y"] = cmp.mapping.confirm({ select = true }), + }, + + sources = { + { name = "nvim_lsp" }, + { name = "buffer" }, + }, +}) + +local lsp_zero = require("lsp-zero") + +lsp_zero.on_attach(function(client, bufnr) + lsp_zero.default_keymaps({ buffer = bufnr }) +end) +require("lspconfig").pyright.setup({ + virtual_text = false, +}) + +local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + +require("lspconfig").clangd.setup({ + capabilities = capabilities, +}) +vim.api.nvim_create_augroup("AutoFormat", {}) + +vim.api.nvim_create_autocmd( +"BufWritePost", +{ + pattern = "*.py", + group = "AutoFormat", + callback = function() + vim.cmd("silent !black --line-length=120 --quiet %") + vim.cmd("edit") + end, +}) + +local function on_list(options) + vim.fn.setqflist({}, ' ', options) + vim.api.nvim_command('cfirst') +end + +local bufopts = { noremap=true, silent=true, buffer=bufnr } +vim.keymap.set('n', 'd', function() vim.lsp.buf.definition{on_list=on_list} end, bufopts) +vim.keymap.set('n', 'r', function() vim.lsp.buf.references(nil, {on_list=on_list}) end, bufopts) diff --git a/tmux.conf b/tmux.conf index 92f7215..0a6e60d 100644 --- a/tmux.conf +++ b/tmux.conf @@ -3,12 +3,32 @@ unbind C-b set-option -g prefix ` bind-key ` send-prefix -# List of plugins set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-resurrect' set -g @plugin 'tmux-plugins/tmux-continuum' set -g @continuum-restore 'on' -# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) -run '~/.tmux/plugins/tpm/tpm' -run-shell ~/clone/path/resurrect.tmux +set -g @continuum-save-interval '1' + + +set -g mouse on +set -g pane-border-style fg=black + +set-option -sg escape-time 10 +set-option -g focus-events on +set-option -g default-terminal "screen-256color" +set-option -ga terminal-overrides ',xterm-256color:Tc' +set-option -g history-limit 30000 +set-window-option -g aggressive-resize +setw -g mode-keys vi +bind-key -T copy-mode-vi y send -X copy-selection-and-cancel +bind -T copy-mode-vi v send -X begin-selection +bind P paste-buffer +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel + +# bind ctrl-C to escape +bind-key -n C-c send-keys Escape + + +run '~/.tmux/plugins/tpm/tpm' +# run-shell ~/clone/path/continuum.tmux diff --git a/vimrc.vim b/vimrc.vim index 7098df5..809c199 100644 --- a/vimrc.vim +++ b/vimrc.vim @@ -1,5 +1,7 @@ set autoindent expandtab tabstop=4 shiftwidth=4 set hidden +let g:python3_host_prog = '/usr/local/vitol/pyenv/versions/3.11.4/bin/python' + " When editing a file, always jump to the last known cursor position. autocmd BufReadPost * @@ -8,7 +10,6 @@ autocmd BufReadPost * \ | endif nnoremap :w -nnoremap :noh nnoremap :bn nnoremap :bp inoremap :wi @@ -16,30 +17,50 @@ let mapleader=" " nnoremap w :w:bw nnoremap W :bw nnoremap v :e ~/.config/nvim/init.lua -nnoremap r :e ~/.config/nvim/vimrc.vim -nnoremap t :e ~/.tmux.conf -nnoremap x :Sex +nnoremap m :e ~/.config/nvim/vimrc.vim nnoremap s :source ~/.config/nvim/init.lua nnoremap q :xa nnoremap f Telescope find_files nnoremap g Telescope live_grep nnoremap b Telescope buffers nnoremap h Telescope help_tags +nnoremap l Lazy nmap j (coc-diagnostic-prev) nmap d (coc-diagnostic-next) -inoremap CheckBackspace() ? "\" : "\" +function! s:c_cycle(count) abort + let qf_info = getqflist({ 'idx': 0, 'size': 0 }) + let size = qf_info->get('size') + if size == 0 + return + endif + + let idx = qf_info->get('idx') + + let num = (idx + size + a:count) % size + + if num == 0 + let num = size + endif + + execute num .. 'cc' +endfunction +command! -nargs=1 CCycle call s:c_cycle() + +nnoremap [n 'CCycle -' .. v:count1 .. '' +nnoremap ]n 'CCycle ' .. v:count1 .. '' vnoremap :m '<-2gv=gv vnoremap :m '>+1gv=gv nnoremap :m -2 nnoremap :m +1 -function! CheckBackspace() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - +augroup tokyonight-night + autocmd! + autocmd ColorScheme * highlight Normal guibg=NONE ctermbg=NONE + autocmd ColorScheme * highlight NonText guibg=NONE ctermbg=NONE +augroup END colorscheme tokyonight-night +set background=dark let g:LanguageClient_useVirtualText = 0 " disable inline errors