From 4b791cb985699bd28fae8ca07fbc3f1474a86c65 Mon Sep 17 00:00:00 2001 From: Daniel Carrillo Date: Sat, 1 Oct 2022 13:46:18 +0200 Subject: [PATCH] Add neovim dotfiles --- .config/alacritty/alacritty.yml | 64 -------- .config/kitty/kitty.conf | 72 +++++---- .config/nvim/README.md | 3 + .config/nvim/init.lua | 27 ++++ .config/nvim/lua/user/autocommands.lua | 45 ++++++ .config/nvim/lua/user/autopairs.lua | 17 +++ .config/nvim/lua/user/autosave.lua | 12 ++ .config/nvim/lua/user/bufferline.lua | 92 ++++++++++++ .config/nvim/lua/user/cmp.lua | 128 ++++++++++++++++ .config/nvim/lua/user/colorscheme.lua | 21 +++ .config/nvim/lua/user/commands.lua | 15 ++ .config/nvim/lua/user/comment.lua | 22 +++ .config/nvim/lua/user/dap.lua | 50 +++++++ .config/nvim/lua/user/diffview.lua | 8 + .config/nvim/lua/user/gitsigns.lua | 14 ++ .config/nvim/lua/user/go.lua | 9 ++ .config/nvim/lua/user/illuminate.lua | 8 + .config/nvim/lua/user/impatient.lua | 6 + .config/nvim/lua/user/indentline.lua | 18 +++ .config/nvim/lua/user/keymaps.lua | 89 +++++++++++ .config/nvim/lua/user/lsp/handlers.lua | 91 ++++++++++++ .config/nvim/lua/user/lsp/init.lua | 8 + .config/nvim/lua/user/lsp/lsp-installer.lua | 46 ++++++ .config/nvim/lua/user/lsp/null-ls.lua | 29 ++++ .../nvim/lua/user/lsp/settings/pyright.lua | 9 ++ .../lua/user/lsp/settings/sumneko_lua.lua | 18 +++ .config/nvim/lua/user/lualine.lua | 73 +++++++++ .config/nvim/lua/user/markdowntoc.lua | 3 + .config/nvim/lua/user/neo-tree.lua | 68 +++++++++ .config/nvim/lua/user/nightfox.lua | 12 ++ .config/nvim/lua/user/options.lua | 44 ++++++ .config/nvim/lua/user/plugins.lua | 139 ++++++++++++++++++ .config/nvim/lua/user/session-manager.lua | 8 + .config/nvim/lua/user/telescope.lua | 42 ++++++ .config/nvim/lua/user/treesitter.lua | 17 +++ .config/nvim/lua/user/trouble.lua | 6 + .config/nvim/lua/user/wilder.lua | 67 +++++++++ .config/polybar/scripts/polywins | 5 +- .vimrc | 14 -- .zshrc | 6 +- README.md | 18 +++ 41 files changed, 1330 insertions(+), 113 deletions(-) delete mode 100644 .config/alacritty/alacritty.yml create mode 100644 .config/nvim/README.md create mode 100644 .config/nvim/init.lua create mode 100644 .config/nvim/lua/user/autocommands.lua create mode 100644 .config/nvim/lua/user/autopairs.lua create mode 100644 .config/nvim/lua/user/autosave.lua create mode 100644 .config/nvim/lua/user/bufferline.lua create mode 100644 .config/nvim/lua/user/cmp.lua create mode 100644 .config/nvim/lua/user/colorscheme.lua create mode 100644 .config/nvim/lua/user/commands.lua create mode 100644 .config/nvim/lua/user/comment.lua create mode 100644 .config/nvim/lua/user/dap.lua create mode 100644 .config/nvim/lua/user/diffview.lua create mode 100644 .config/nvim/lua/user/gitsigns.lua create mode 100644 .config/nvim/lua/user/go.lua create mode 100644 .config/nvim/lua/user/illuminate.lua create mode 100644 .config/nvim/lua/user/impatient.lua create mode 100644 .config/nvim/lua/user/indentline.lua create mode 100644 .config/nvim/lua/user/keymaps.lua create mode 100644 .config/nvim/lua/user/lsp/handlers.lua create mode 100644 .config/nvim/lua/user/lsp/init.lua create mode 100644 .config/nvim/lua/user/lsp/lsp-installer.lua create mode 100644 .config/nvim/lua/user/lsp/null-ls.lua create mode 100644 .config/nvim/lua/user/lsp/settings/pyright.lua create mode 100644 .config/nvim/lua/user/lsp/settings/sumneko_lua.lua create mode 100644 .config/nvim/lua/user/lualine.lua create mode 100644 .config/nvim/lua/user/markdowntoc.lua create mode 100644 .config/nvim/lua/user/neo-tree.lua create mode 100644 .config/nvim/lua/user/nightfox.lua create mode 100644 .config/nvim/lua/user/options.lua create mode 100644 .config/nvim/lua/user/plugins.lua create mode 100644 .config/nvim/lua/user/session-manager.lua create mode 100644 .config/nvim/lua/user/telescope.lua create mode 100644 .config/nvim/lua/user/treesitter.lua create mode 100644 .config/nvim/lua/user/trouble.lua create mode 100644 .config/nvim/lua/user/wilder.lua delete mode 100644 .vimrc create mode 100644 README.md diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml deleted file mode 100644 index a1ba30b..0000000 --- a/.config/alacritty/alacritty.yml +++ /dev/null @@ -1,64 +0,0 @@ -# Configuration for Alacritty, the GPU enhanced terminal emulator. - -# Any items in the `env` entry below will be added as -# environment variables. Some entries may override variables -# set by alacritty itself. -env: - TERM: xterm-256color - # LANG: "en_US.UTF-8" - # LC_CTYPE: en_US.UTF-8 - -shell: - program: /bin/zsh - args: - - -l - - -c - - "tmux attach || tmux" - -window: - dimensions: - columns: 150 - lines: 35 - position: - x: 1200 - y: 510 - scrolling: - history: 50000 - -cursor: - style: Underline - -selection: - semantic_escape_chars: ",│`|:\"' ()[]{}<>\t" - -font: - normal: - family: "Roboto Mono" - style: Regular - size: 9.0 - use_thin_strokes: true - -colors: - primary: - background: '#073642' - foreground: '#BABABA' - - normal: - black: '#000000' - red: '#E8341C' - green: '#68C256' - yellow: '#F2D42C' - blue: '#1C98E8' - magenta: '#8E69C9' - cyan: '#1C98E8' - white: '#BABABA' - - bright: - black: '#666666' - red: '#E05A4F' - green: '#77B869' - yellow: '#EFD64B' - blue: '#387CD3' - magenta: '#957BBE' - cyan: '#3D97E2' - white: '#BABABA' diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf index 87385f1..2eb895e 100644 --- a/.config/kitty/kitty.conf +++ b/.config/kitty/kitty.conf @@ -37,9 +37,10 @@ enable_audio_bell no enabled_layouts vertical,fat,grid,horizontal,splits,stack,tall +# resize_in_steps yes remember_window_size no -initial_window_width 2100 -initial_window_height 1150 +initial_window_width 2110 +initial_window_height 1160 window_padding_width 1 active_border_color #C0C0C0 @@ -47,40 +48,49 @@ active_border_color #C0C0C0 #: Color scheme {{{ -foreground #BABABA -background #073642 +## name: Tokyo Night +## license: MIT +## author: Folke Lemaitre +## upstream: https://github.com/folke/tokyonight.nvim/raw/main/extras/kitty/tokyonight_night.conf -#: black -color0 #000000 -color8 #666666 +background #24283b +foreground #c0caf5 +selection_background #33467c +selection_foreground #c0caf5 +url_color #73daca +cursor #c0caf5 +cursor_text_color #1a1b26 -#: red -color1 #E8341C -color9 #E05A4F +# Tabs +active_tab_background #7aa2f7 +active_tab_foreground #16161e +inactive_tab_background #292e42 +inactive_tab_foreground #545c7e +#tab_bar_background #15161e -#: green -color2 #68C256 -color10 #77B869 +# normal +color0 #15161e +color1 #f7768e +color2 #9ece6a +color3 #e0af68 +color4 #7aa2f7 +color5 #bb9af7 +color6 #7dcfff +color7 #a9b1d6 -#: yellow -color3 #F2D42C -color11 #EFD64B +# bright +color8 #414868 +color9 #f7768e +color10 #9ece6a +color11 #e0af68 +color12 #7aa2f7 +color13 #bb9af7 +color14 #7dcfff +color15 #c0caf5 -#: blue -color4 #1C98E8 -color12 #387CD3 - -#: magenta -color5 #8E69C9 -color13 #957BBE - -#: cyan -color6 #1C98E8 -color14 #3D97E2 - -#: white -color7 #BABABA -color15 #BABABA +# extended colors +color16 #ff9e64 +color17 #db4b4b #: }}} diff --git a/.config/nvim/README.md b/.config/nvim/README.md new file mode 100644 index 0000000..7a74bf4 --- /dev/null +++ b/.config/nvim/README.md @@ -0,0 +1,3 @@ +# Neovim configuration files + +Neovim conf heavily adapted to suit my needs, based on LunarVim's [basic ide](https://github.com/LunarVim/nvim-basic-ide). diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..163a886 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,27 @@ +require("user.options") +require("user.keymaps") +require("user.plugins") +require("user.autocommands") +require("user.commands") +require("user.colorscheme") +require("user.cmp") +require("user.telescope") +require("user.treesitter") +require("user.autopairs") +require("user.comment") +require("user.gitsigns") +require("user.neo-tree") +require("user.bufferline") +require("user.lualine") +require("user.impatient") +require("user.illuminate") +require("user.indentline") +require("user.lsp") +require("user.dap") +require("user.go") +require("user.wilder") +require("user.trouble") +require("user.autosave") +require("user.markdowntoc") +require("user.session-manager") +require("user.diffview") diff --git a/.config/nvim/lua/user/autocommands.lua b/.config/nvim/lua/user/autocommands.lua new file mode 100644 index 0000000..d065126 --- /dev/null +++ b/.config/nvim/lua/user/autocommands.lua @@ -0,0 +1,45 @@ +vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif") + +-- Fixes Autocomment +vim.api.nvim_create_autocmd({ "BufWinEnter" }, { + callback = function() + vim.cmd("set formatoptions-=cro") + end, +}) + +-- Highlight Yanked Text +vim.api.nvim_create_autocmd({ "TextYankPost" }, { + callback = function() + vim.highlight.on_yank({ higroup = "Visual", timeout = 200 }) + end, +}) + +-- Set options by FileType + +-- Set wrap and spell in markdown and gitcommit +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +-- Set wrap and spell in markdown and gitcommit +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "go", "makefile", "lua" }, + callback = function() + vim.opt_local.expandtab = false + end, +}) + +-- Use 'q' to quit from common plugins +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "qf", "help", "man", "lspinfo", "spectre_panel", "lir" }, + callback = function() + vim.cmd([[ + nnoremap q :close + set nobuflisted + ]]) + end, +}) diff --git a/.config/nvim/lua/user/autopairs.lua b/.config/nvim/lua/user/autopairs.lua new file mode 100644 index 0000000..2cf6873 --- /dev/null +++ b/.config/nvim/lua/user/autopairs.lua @@ -0,0 +1,17 @@ +-- Setup nvim-cmp. +local status_ok, npairs = pcall(require, "nvim-autopairs") +if not status_ok then + return +end + +npairs.setup({ + check_ts = true, -- treesitter integration + disable_filetype = { "TelescopePrompt" }, +}) + +local cmp_autopairs = require("nvim-autopairs.completion.cmp") +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({})) diff --git a/.config/nvim/lua/user/autosave.lua b/.config/nvim/lua/user/autosave.lua new file mode 100644 index 0000000..8e944ba --- /dev/null +++ b/.config/nvim/lua/user/autosave.lua @@ -0,0 +1,12 @@ +local status_ok, autosave = pcall(require, "autosave") +if not status_ok then + return +end + +autosave.setup({ + execution_message = { + message = function() + return "" + end, + }, +}) diff --git a/.config/nvim/lua/user/bufferline.lua b/.config/nvim/lua/user/bufferline.lua new file mode 100644 index 0000000..655cd76 --- /dev/null +++ b/.config/nvim/lua/user/bufferline.lua @@ -0,0 +1,92 @@ +local status_ok, bufferline = pcall(require, "bufferline") +if not status_ok then + return +end + +bufferline.setup({ + options = { + close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + offsets = { { filetype = "neo-tree", text = "", padding = 1 } }, + separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' }, + }, + highlights = { + fill = { + fg = { attribute = "fg", highlight = "#ff0000" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + background = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + buffer_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + close_button = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + close_button_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + tab_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + tab = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + tab_close = { + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + + duplicate_selected = { + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "TabLineSel" }, + italic = true, + }, + duplicate_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + italic = true, + }, + duplicate = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + italic = true, + }, + + modified = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + modified_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + modified_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + separator = { + fg = { attribute = "bg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + separator_selected = { + fg = { attribute = "bg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + indicator_selected = { + fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + }, +}) diff --git a/.config/nvim/lua/user/cmp.lua b/.config/nvim/lua/user/cmp.lua new file mode 100644 index 0000000..1eb816b --- /dev/null +++ b/.config/nvim/lua/user/cmp.lua @@ -0,0 +1,128 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end + +local snip_status_ok, luasnip = pcall(require, "luasnip") +if not snip_status_ok then + return +end + +require("luasnip/loaders/from_vscode").lazy_load() + +local check_backspace = function() + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") +end + +local kind_icons = { + Text = "", + Method = "", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", +} + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + }), + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + vim_item.kind = kind_icons[vim_item.kind] + vim_item.menu = ({ + nvim_lsp = "", + nvim_lua = "", + luasnip = "", + buffer = "", + path = "", + emoji = "", + })[entry.source.name] + return vim_item + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + experimental = { + ghost_text = true, + }, +}) diff --git a/.config/nvim/lua/user/colorscheme.lua b/.config/nvim/lua/user/colorscheme.lua new file mode 100644 index 0000000..278fc4a --- /dev/null +++ b/.config/nvim/lua/user/colorscheme.lua @@ -0,0 +1,21 @@ +local colorscheme = "tokyonight" + +-- if colorscheme == "nightfox" then +-- local status_nf_ok, nightfox = pcall(require, "nightfox") +-- if not status_nf_ok then +-- return +-- end +-- +-- local palettes = { +-- nightfox = { +-- bg1 = "#24283b", +-- }, +-- } +-- +-- nightfox.setup({ palettes = palettes }) +-- end + +local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) +if not status_ok then + return +end diff --git a/.config/nvim/lua/user/commands.lua b/.config/nvim/lua/user/commands.lua new file mode 100644 index 0000000..3d72f55 --- /dev/null +++ b/.config/nvim/lua/user/commands.lua @@ -0,0 +1,15 @@ +vim.api.nvim_create_user_command("CopyBufferPath", function() + local path = vim.fn.expand("%:p") + vim.fn.setreg("+", path) + vim.notify('Copied "' .. path .. '" to the clipboard!') +end, {}) + +vim.api.nvim_create_user_command("CopyDirectoryPath", function() + local path = vim.fn.expand("%:p:h") + vim.fn.setreg("+", path) + vim.notify('Copied "' .. path .. '" to the clipboard!') +end, {}) + +vim.api.nvim_create_user_command("RemoveTrailingSpaces", function() + vim.cmd("% s/\\s\\+$//e") +end, {}) diff --git a/.config/nvim/lua/user/comment.lua b/.config/nvim/lua/user/comment.lua new file mode 100644 index 0000000..07c1a2a --- /dev/null +++ b/.config/nvim/lua/user/comment.lua @@ -0,0 +1,22 @@ +local status_ok, comment = pcall(require, "Comment") +if not status_ok then + return +end + +comment.setup({ + pre_hook = function(ctx) + local U = require("Comment.utils") + + local location = nil + if ctx.ctype == U.ctype.block then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require("ts_context_commentstring.utils").get_visual_start_location() + end + + return require("ts_context_commentstring.internal").calculate_commentstring({ + key = ctx.ctype == U.ctype.line and "__default" or "__multiline", + location = location, + }) + end, +}) diff --git a/.config/nvim/lua/user/dap.lua b/.config/nvim/lua/user/dap.lua new file mode 100644 index 0000000..7b6d732 --- /dev/null +++ b/.config/nvim/lua/user/dap.lua @@ -0,0 +1,50 @@ +local dap_status_ok, dap = pcall(require, "dap") +if not dap_status_ok then + return +end + +local dap_ui_status_ok, dapui = pcall(require, "dapui") +if not dap_ui_status_ok then + return +end + +local dap_install_status_ok, dap_install = pcall(require, "dap-install") +if not dap_install_status_ok then + return +end + +dap_install.setup({}) + +dap_install.config("python", {}) +-- add other configs here + +dapui.setup({}) +-- deprecated +-- sidebar = { +-- elements = { +-- { +-- id = "scopes", +-- size = 0.25, -- Can be float or integer > 1 +-- }, +-- { id = "breakpoints", size = 0.25 }, +-- }, +-- size = 40, +-- position = "right", -- Can be "left", "right", "top", "bottom" +-- }, +-- tray = { +-- elements = {}, +-- }, + +vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" }) + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end + +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end + +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end diff --git a/.config/nvim/lua/user/diffview.lua b/.config/nvim/lua/user/diffview.lua new file mode 100644 index 0000000..4a13481 --- /dev/null +++ b/.config/nvim/lua/user/diffview.lua @@ -0,0 +1,8 @@ +local status_ok, diffview = pcall(require, "diffview") +if not status_ok then + return +end + +diffview.setup({}) + +vim.opt.fillchars = "diff: " diff --git a/.config/nvim/lua/user/gitsigns.lua b/.config/nvim/lua/user/gitsigns.lua new file mode 100644 index 0000000..6af70f4 --- /dev/null +++ b/.config/nvim/lua/user/gitsigns.lua @@ -0,0 +1,14 @@ +local status_ok, gitsigns = pcall(require, "gitsigns") +if not status_ok then + return +end + +gitsigns.setup({ + signs = { + add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + }, +}) diff --git a/.config/nvim/lua/user/go.lua b/.config/nvim/lua/user/go.lua new file mode 100644 index 0000000..e1fb3e9 --- /dev/null +++ b/.config/nvim/lua/user/go.lua @@ -0,0 +1,9 @@ +local status_ok, go = pcall(require, "go") +if not status_ok then + return +end + +vim.cmd("autocmd FileType go nmap gf :lua require('go.format').goimport()") +go.setup({ + icons = { breakpoint = "", currentpos = "🏃" }, +}) diff --git a/.config/nvim/lua/user/illuminate.lua b/.config/nvim/lua/user/illuminate.lua new file mode 100644 index 0000000..67ac6f2 --- /dev/null +++ b/.config/nvim/lua/user/illuminate.lua @@ -0,0 +1,8 @@ +vim.g.Illuminate_ftblacklist = { "neo-tree" } +vim.api.nvim_set_keymap("n", "", 'lua require"illuminate".next_reference{wrap=true}', { noremap = true }) +vim.api.nvim_set_keymap( + "n", + "", + 'lua require"illuminate".next_reference{reverse=true,wrap=true}', + { noremap = true } +) diff --git a/.config/nvim/lua/user/impatient.lua b/.config/nvim/lua/user/impatient.lua new file mode 100644 index 0000000..fa64f00 --- /dev/null +++ b/.config/nvim/lua/user/impatient.lua @@ -0,0 +1,6 @@ +local status_ok, impatient = pcall(require, "impatient") +if not status_ok then + return +end + +impatient.enable_profile() diff --git a/.config/nvim/lua/user/indentline.lua b/.config/nvim/lua/user/indentline.lua new file mode 100644 index 0000000..79525c7 --- /dev/null +++ b/.config/nvim/lua/user/indentline.lua @@ -0,0 +1,18 @@ +local status_ok, indent_blankline = pcall(require, "indent_blankline") +if not status_ok then + return +end + +indent_blankline.setup({ + char = "▏", + show_trailing_blankline_indent = false, + show_first_indent_level = true, + use_treesitter = true, + show_current_context = true, + buftype_exclude = { "terminal", "nofile" }, + filetype_exclude = { + "help", + "packer", + "NvimTree", + }, +}) diff --git a/.config/nvim/lua/user/keymaps.lua b/.config/nvim/lua/user/keymaps.lua new file mode 100644 index 0000000..9b7e66d --- /dev/null +++ b/.config/nvim/lua/user/keymaps.lua @@ -0,0 +1,89 @@ +-- Shorten function name +local keymap = vim.keymap.set +-- Silent keymap option +local opts = { silent = true } + +--Remap space as leader key +keymap("", "", "", opts) +vim.g.mapleader = " " + +-- Modes +-- normal_mode = "n", +-- insert_mode = "i", +-- visual_mode = "v", +-- visual_block_mode = "x", +-- term_mode = "t", +-- command_mode = "c", + +-- Normal -- +-- Better window navigation +keymap("n", "", "h", opts) +keymap("n", "", "j", opts) +keymap("n", "", "k", opts) +keymap("n", "", "l", opts) + +-- Resize with arrows +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) + +-- Navigate buffers +keymap("n", "", ":bnext", opts) +keymap("n", "", ":bprevious", opts) + +-- Clear highlights +keymap("n", "h", "nohlsearch", opts) + +-- Close buffers +keymap("n", "", "Bdelete!", opts) + +-- Toogle Trouble +keymap("n", "xx", "TroubleToggle", opts) +keymap("n", "xw", "TroubleToggle workspace_diagnostics", opts) +keymap("n", "xd", "TroubleToggle document_diagnostics", opts) +keymap("n", "xl", "TroubleToggle loclist", opts) +keymap("n", "xq", "TroubleToggle quickfix", opts) +keymap("n", "gR", "TroubleToggle lsp_references", opts) + +-- Better paste +keymap("v", "p", '"_dP', opts) + +-- Insert -- +-- Press jk fast to enter +keymap("i", "jk", "", opts) + +-- Visual -- +-- Stay in indent mode +keymap("v", "<", "", ">gv", opts) + +-- NeoTree +keymap("n", "e", ":Neotree toggle", opts) +keymap("n", "gg", ":Neotree float git_status", opts) + +-- Telescope +keymap("n", "ff", ":Telescope find_files", opts) +keymap("n", "", ":Telescope find_files", opts) +keymap("n", "fg", ":Telescope live_grep", opts) +keymap("n", "fb", ":Telescope buffers", opts) + +-- Comment +keymap("n", "/", "lua require('Comment.api').toggle_current_linewise()", opts) +keymap("x", "/", 'lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())') + +-- DAP +keymap("n", "db", "lua require'dap'.toggle_breakpoint()", opts) +keymap("n", "dc", "lua require'dap'.continue()", opts) +keymap("n", "di", "lua require'dap'.step_into()", opts) +keymap("n", "do", "lua require'dap'.step_over()", opts) +keymap("n", "dO", "lua require'dap'.step_out()", opts) +keymap("n", "dr", "lua require'dap'.repl.toggle()", opts) +keymap("n", "dl", "lua require'dap'.run_last()", opts) +keymap("n", "du", "lua require'dapui'.toggle()", opts) +keymap("n", "dt", "lua require'dap'.terminate()", opts) + +-- Session Manager +keymap("n", "so", ":SessionManager load_session", opts) +keymap("n", "sd", ":SessionManager delete_session", opts) +keymap("n", "ss", ":SessionManager save_current_session", opts) diff --git a/.config/nvim/lua/user/lsp/handlers.lua b/.config/nvim/lua/user/lsp/handlers.lua new file mode 100644 index 0000000..baaa7fa --- /dev/null +++ b/.config/nvim/lua/user/lsp/handlers.lua @@ -0,0 +1,91 @@ +local M = {} + +local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not status_cmp_ok then + return +end + +M.capabilities = vim.lsp.protocol.make_client_capabilities() +M.capabilities.textDocument.completion.completionItem.snippetSupport = true +M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities) + +M.setup = function() + local signs = { + + { name = "DiagnosticSignError", text = "" }, + { name = "DiagnosticSignWarn", text = "" }, + { name = "DiagnosticSignHint", text = "" }, + { name = "DiagnosticSignInfo", text = "" }, + } + + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end + + local config = { + virtual_text = false, -- disable virtual text + signs = { + active = signs, -- show signs + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = true, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +local function lsp_keymaps(bufnr) + local opts = { noremap = true, silent = true } + local keymap = vim.api.nvim_buf_set_keymap + keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) + keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) + keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) + keymap(bufnr, "n", "gI", "lua vim.lsp.buf.implementation()", opts) + keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) + keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) + keymap(bufnr, "n", "lf", "lua vim.lsp.buf.formatting()", opts) + -- keymap(bufnr, "n", "li", "LspInfo", opts) + -- keymap(bufnr, "n", "lI", "LspInstallInfo", opts) + keymap(bufnr, "n", "la", "lua vim.lsp.buf.code_action()", opts) + keymap(bufnr, "n", "lj", "lua vim.diagnostic.goto_next({buffer=0})", opts) + keymap(bufnr, "n", "lk", "lua vim.diagnostic.goto_prev({buffer=0})", opts) + keymap(bufnr, "n", "lr", "lua vim.lsp.buf.rename()", opts) + keymap(bufnr, "n", "ls", "lua vim.lsp.buf.signature_help()", opts) + keymap(bufnr, "n", "lq", "lua vim.diagnostic.setloclist()", opts) +end + +M.on_attach = function(client, bufnr) + if client.name == "tsserver" then + client.resolved_capabilities.document_formatting = false + end + + if client.name == "sumneko_lua" then + client.resolved_capabilities.document_formatting = false + end + + lsp_keymaps(bufnr) + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) +end + +return M diff --git a/.config/nvim/lua/user/lsp/init.lua b/.config/nvim/lua/user/lsp/init.lua new file mode 100644 index 0000000..94a571e --- /dev/null +++ b/.config/nvim/lua/user/lsp/init.lua @@ -0,0 +1,8 @@ +local status_ok, _ = pcall(require, "lspconfig") +if not status_ok then + return +end + +require("user.lsp.lsp-installer") +require("user.lsp.handlers").setup() +require("user.lsp.null-ls") diff --git a/.config/nvim/lua/user/lsp/lsp-installer.lua b/.config/nvim/lua/user/lsp/lsp-installer.lua new file mode 100644 index 0000000..68740c4 --- /dev/null +++ b/.config/nvim/lua/user/lsp/lsp-installer.lua @@ -0,0 +1,46 @@ +local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") +if not status_ok then + return +end + +local servers = { + "sumneko_lua", + -- "cssls", + -- "html", + -- "tsserver", + "gopls", + -- "grammarly", + "golangci_lint_ls", + "pyright", + "bashls", + "jsonls", + "yamlls", +} + +lsp_installer.setup() + +local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status_ok then + return +end + +local opts = {} + +for _, server in pairs(servers) do + opts = { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + + if server == "sumneko_lua" then + local sumneko_opts = require("user.lsp.settings.sumneko_lua") + opts = vim.tbl_deep_extend("force", sumneko_opts, opts) + end + + if server == "pyright" then + local pyright_opts = require("user.lsp.settings.pyright") + opts = vim.tbl_deep_extend("force", pyright_opts, opts) + end + + lspconfig[server].setup(opts) +end diff --git a/.config/nvim/lua/user/lsp/null-ls.lua b/.config/nvim/lua/user/lsp/null-ls.lua new file mode 100644 index 0000000..fb56b76 --- /dev/null +++ b/.config/nvim/lua/user/lsp/null-ls.lua @@ -0,0 +1,29 @@ +local null_ls_status_ok, null_ls = pcall(require, "null-ls") +if not null_ls_status_ok then + return +end + +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting +local formatting = null_ls.builtins.formatting +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics +local diagnostics = null_ls.builtins.diagnostics + +-- https://github.com/prettier-solidity/prettier-plugin-solidity +null_ls.setup({ + debug = false, + sources = { + formatting.prettier.with({ + extra_filetypes = { "toml" }, + extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" }, + }), + formatting.black.with({ extra_args = { "--fast" } }), + formatting.stylua, + diagnostics.golangci_lint.with({ extra_args = { "--fast" } }), + diagnostics.flake8.with({ + extra_args = { "--max-line-length=120" }, + }), + diagnostics.cfn_lint, + diagnostics.shellcheck, + diagnostics.hadolint, + }, +}) diff --git a/.config/nvim/lua/user/lsp/settings/pyright.lua b/.config/nvim/lua/user/lsp/settings/pyright.lua new file mode 100644 index 0000000..570ef9d --- /dev/null +++ b/.config/nvim/lua/user/lsp/settings/pyright.lua @@ -0,0 +1,9 @@ +return { + settings = { + python = { + analysis = { + typeCheckingMode = "off", + }, + }, + }, +} diff --git a/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua b/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua new file mode 100644 index 0000000..0f61fe4 --- /dev/null +++ b/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua @@ -0,0 +1,18 @@ +return { + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + telemetry = { + enable = false, + }, + }, + }, +} diff --git a/.config/nvim/lua/user/lualine.lua b/.config/nvim/lua/user/lualine.lua new file mode 100644 index 0000000..65407dd --- /dev/null +++ b/.config/nvim/lua/user/lualine.lua @@ -0,0 +1,73 @@ +local status_ok, lualine = pcall(require, "lualine") +if not status_ok then + return +end + +local hide_in_width = function() + return vim.fn.winwidth(0) > 80 +end + +local diagnostics = { + "diagnostics", + sources = { "nvim_diagnostic" }, + sections = { "error", "warn" }, + symbols = { error = " ", warn = " " }, + colored = false, + always_visible = true, +} + +local diff = { + "diff", + colored = false, + symbols = { added = "", modified = "", removed = "" }, -- changes diff symbols + cond = hide_in_width, +} + +local filetype = { + "filetype", + icons_enabled = false, +} + +local location = { + "location", + padding = 0, +} + +local spaces = function() + return "spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") +end + +local gitblame_status_ok, gitblame = pcall(require, "gitblame") +if not gitblame_status_ok then + return +end + +vim.g.gitblame_date_format = "%r" +vim.g.gitblame_display_virtual_text = 0 +vim.g.gitblame_message_template = ", " + +lualine.setup({ + options = { + globalstatus = true, + icons_enabled = true, + theme = "auto", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { "alpha", "dashboard" }, + always_divide_middle = true, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch" }, + lualine_c = { diagnostics, { "filename", path = 3 } }, + lualine_x = { + { gitblame.get_current_blame_text, cond = gitblame.is_blame_text_available }, + diff, + spaces, + "encoding", + filetype, + }, + lualine_y = { location }, + lualine_z = { "progress" }, + }, +}) diff --git a/.config/nvim/lua/user/markdowntoc.lua b/.config/nvim/lua/user/markdowntoc.lua new file mode 100644 index 0000000..522f9d1 --- /dev/null +++ b/.config/nvim/lua/user/markdowntoc.lua @@ -0,0 +1,3 @@ +vim.g.vmt_dont_insert_fence = true +vim.g.vmt_list_item_char = "-" +vim.g.vmt_include_headings_before = true diff --git a/.config/nvim/lua/user/neo-tree.lua b/.config/nvim/lua/user/neo-tree.lua new file mode 100644 index 0000000..8794d1c --- /dev/null +++ b/.config/nvim/lua/user/neo-tree.lua @@ -0,0 +1,68 @@ +local status_ok, neotree = pcall(require, "neo-tree") +if not status_ok then + return +end + +vim.g.neo_tree_remove_legacy_commands = true + +neotree.setup({ + popup_border_style = "rounded", + default_component_configs = { + indent = { + padding = 0, + with_expanders = false, + }, + icon = { + folder_closed = "", + folder_open = "", + folder_empty = "", + default = "", + }, + git_status = { + symbols = { + added = "", + deleted = "", + modified = "", + renamed = "➜", + untracked = "★", + ignored = "◌", + unstaged = "✗", + staged = "✓", + conflict = "", + }, + }, + }, + window = { + width = 40, + mappings = { + ["o"] = "open", + ["Z"] = "expand_all_nodes", + }, + }, + filesystem = { + filtered_items = { + visible = false, + hide_dotfiles = true, + hide_gitignored = false, + hide_by_name = { + "__pycache__", + }, + }, + follow_current_file = true, + hijack_netrw_behavior = "open_current", + use_libuv_file_watcher = true, + }, + git_status = { + window = { + position = "float", + }, + }, + event_handlers = { + { + event = "neo_tree_buffer_enter", + handler = function(_) + vim.opt_local.signcolumn = "auto" + end, + }, + }, +}) diff --git a/.config/nvim/lua/user/nightfox.lua b/.config/nvim/lua/user/nightfox.lua new file mode 100644 index 0000000..3c9c800 --- /dev/null +++ b/.config/nvim/lua/user/nightfox.lua @@ -0,0 +1,12 @@ +local status_nf_ok, nightfox = pcall(require, "nightfox") +if not status_nf_ok then + return +end + +local palettes = { + nightfox = { + bg1 = "#1c1e26", + }, +} + +nightfox.setup({ palettes = palettes }) diff --git a/.config/nvim/lua/user/options.lua b/.config/nvim/lua/user/options.lua new file mode 100644 index 0000000..e016528 --- /dev/null +++ b/.config/nvim/lua/user/options.lua @@ -0,0 +1,44 @@ +vim.opt.backup = false -- creates a backup file +vim.opt.autowriteall = true +vim.opt.clipboard = "unnamedplus" -- allows neovim to access the system clipboard +vim.opt.cmdheight = 1 -- more space in the neovim command line for displaying messages +vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp +vim.opt.conceallevel = 0 -- so that `` is visible in markdown files +vim.opt.fileencoding = "utf-8" -- the encoding written to a file +vim.opt.hlsearch = true -- highlight all matches on previous search pattern +vim.opt.ignorecase = false -- ignore case in search patterns +vim.opt.mouse = "a" -- allow the mouse to be used in neovim +vim.opt.pumheight = 10 -- pop up menu height +vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore +vim.opt.showtabline = 0 -- always show tabs +vim.opt.smartcase = true -- smart case +vim.opt.smartindent = true -- make indenting smarter again +vim.opt.splitbelow = true -- force all horizontal splits to go below current window +vim.opt.splitright = true -- force all vertical splits to go to the right of current window +vim.opt.swapfile = false -- creates a swapfile +vim.opt.termguicolors = true -- set term gui colors (most terminals support this) +vim.opt.timeoutlen = 1000 -- time to wait for a mapped sequence to complete (in milliseconds) +vim.opt.undofile = true -- enable persistent undo +vim.opt.updatetime = 300 -- faster completion (4000ms default) +vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited +vim.opt.cursorline = true -- highlight the current line +vim.opt.number = true -- set numbered lines +vim.opt.laststatus = 3 +vim.opt.showcmd = false +vim.opt.ruler = false +-- vim.opt.cc = "80" +vim.opt.listchars = "tab: ,trail:Ç" +vim.opt.list = true +vim.opt.expandtab = true -- convert tabs to spaces +vim.opt.shiftwidth = 4 -- the number of spaces inserted for each indentation +vim.opt.tabstop = 4 -- insert 4 spaces for a tab +vim.opt.numberwidth = 4 -- set number column width to 2 {default 4} +vim.opt.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time +vim.opt.wrap = false -- display lines as one long line +vim.opt.scrolloff = 8 -- is one of my fav +vim.opt.sidescrolloff = 8 +vim.opt.guifont = "monospace:h17" -- the font used in graphical neovim applications +vim.opt.fillchars.eob = " " +vim.opt.shortmess:append("c") +vim.opt.whichwrap:append("<,>,[,],h,l") +vim.opt.iskeyword:append("-") diff --git a/.config/nvim/lua/user/plugins.lua b/.config/nvim/lua/user/plugins.lua new file mode 100644 index 0000000..a247af4 --- /dev/null +++ b/.config/nvim/lua/user/plugins.lua @@ -0,0 +1,139 @@ +local fn = vim.fn +-- Automatically install packer +local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system({ + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + }) + print("Installing packer close and reopen Neovim...") + vim.cmd([[packadd packer.nvim]]) +end + +-- Autocommand that reloads neovim whenever you save the plugins.lua file +-- vim.cmd([[ +-- augroup packer_user_config +-- autocmd! +-- autocmd BufWritePost plugins.lua source | PackerSync +-- augroup end +-- ]]) + +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +-- Have packer use a popup window +packer.init({ + display = { + open_fn = function() + return require("packer.util").float({ border = "rounded" }) + end, + }, +}) + +-- Install your plugins here +return packer.startup(function(use) + -- Plugins + use({ "wbthomason/packer.nvim", commit = "6afb67460283f0e990d35d229fd38fdc04063e0a" }) + use({ "nvim-lua/plenary.nvim", commit = "4b7e52044bbb84242158d977a50c4cbcd85070c7" }) + use({ "windwp/nvim-autopairs", commit = "14cc2a4fc6243152ba085cc2059834113496c60a" }) + use({ "numToStr/Comment.nvim", tag = "v0.6.1" }) + use({ "JoosepAlviste/nvim-ts-context-commentstring", commit = "4d3a68c41a53add8804f471fcc49bb398fe8de08" }) + use({ "kyazdani42/nvim-web-devicons", commit = "563f3635c2d8a7be7933b9e547f7c178ba0d4352" }) + use({ "akinsho/bufferline.nvim", tag = "v2.*" }) + use({ "moll/vim-bbye", commit = "25ef93ac5a87526111f43e5110675032dbcacf56" }) + use({ "nvim-lualine/lualine.nvim", commit = "3362b28f917acc37538b1047f187ff1b5645ecdd" }) + use({ "lewis6991/impatient.nvim", commit = "b842e16ecc1a700f62adb9802f8355b99b52a5a6" }) + use({ "lukas-reineke/indent-blankline.nvim", tag = "v2.*" }) + use({ "Pocco81/auto-save.nvim", commit = "2c7a2943340ee2a36c6a61db812418fca1f57866" }) + use({ "gelguy/wilder.nvim", commit = "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }) + use({ "romgrk/fzy-lua-native", commit = "085c7d262aa35cc55a8523e8c1618d398bf717a", run = "make" }) + use({ "mg979/vim-visual-multi", tag = "v0.*" }) + use({ "Shatur/neovim-session-manager", commit = "4005dac93f5cd1257792259ef4df6af0e3afc213" }) + use({ "nvim-treesitter/nvim-treesitter", commit = "aebc6cf6bd4675ac86629f516d612ad5288f7868" }) + use({ + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + requires = { "MunifTanjim/nui.nvim", commit = "e9889bbd9919544697d497537acacd9c67d0de99" }, + }) + + -- Colorschemes + use({ "folke/tokyonight.nvim", commit = "4092905fc570a721128af73f6bf78e5d47f5edce" }) + use({ "EdenEast/nightfox.nvim", commit = "59c3dbcec362eff7794f1cb576d56fd8a3f2c8bb" }) + + -- cmp plugins + use({ "hrsh7th/nvim-cmp", commit = "2427d06b6508489547cd30b6e86b1c75df363411" }) + use({ "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" }) + use({ "hrsh7th/cmp-path", commit = "447c87cdd6e6d6a1d2488b1d43108bfa217f56e1" }) + use({ "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36" }) + use({ "hrsh7th/cmp-nvim-lsp", commit = "affe808a5c56b71630f17aa7c38e15c59fd648a8" }) + use({ "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21" }) + + -- snippets + use({ "L3MON4D3/LuaSnip", tag = "v1.*" }) + use({ "rafamadriz/friendly-snippets", commit = "2be79d8a9b03d4175ba6b3d14b082680de1b31b1" }) + + -- LSP + use({ "neovim/nvim-lspconfig", commit = "af43c300d4134db3550089cd4df6c257e3734689" }) + use({ "williamboman/nvim-lsp-installer", commit = "e9f13d7acaa60aff91c58b923002228668c8c9e6" }) + use({ "jose-elias-alvarez/null-ls.nvim", commit = "c0c19f32b614b3921e17886c541c13a72748d450" }) + use({ "RRethy/vim-illuminate", commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" }) + use({ "folke/trouble.nvim", commit = "929315ea5f146f1ce0e784c76c943ece6f36d786" }) + + -- Telescope + use({ "nvim-telescope/telescope.nvim", commit = "76ea9a898d3307244dce3573392dcf2cc38f340f" }) + use({ "nvim-telescope/telescope-ui-select.nvim", commit = "62ea5e58c7bbe191297b983a9e7e89420f581369" }) + use({ + "nvim-telescope/telescope-fzf-native.nvim", + commit = "65c0ee3d4bb9cb696e262bca1ea5e9af3938fc90", + run = "make", + }) + + -- Git + use({ "lewis6991/gitsigns.nvim", tag = "v0.5*" }) + use({ "sindrets/diffview.nvim", commit = "6baa30d0a6f63da254c2d2c0638a426166973976" }) + use({ "f-person/git-blame.nvim", commit = "08e75b7061f4a654ef62b0cac43a9015c87744a2" }) + + -- DAP + use({ "mfussenegger/nvim-dap", tag = "0.3*" }) + use({ "rcarriga/nvim-dap-ui", tag = "v2.*" }) + use({ "ravenxrz/DAPInstall.nvim", commit = "8798b4c36d33723e7bba6ed6e2c202f84bb300de" }) + use({ "theHamsta/nvim-dap-virtual-text", commit = "2971ce3e89b1711cc26e27f73d3f854b559a77d4" }) + + -- golang + use({ "ray-x/go.nvim", commit = "24270e540b96bcd6c0c8184532b93a5d4a55c38b" }) + use({ + "ray-x/guihua.lua", + commit = "baebba3ba0e621eb04f5ac32a946935fdf5f5b87", + run = "cd lua/fzy && make", + + config = function() + require("guihua.maps").setup({ + maps = { close_view = "" }, + }) + end, + }) + + -- markdown + use({ "mzlogin/vim-markdown-toc", commit = "7ec05df27b4922830ace2246de36ac7e53bea1db" }) + use({ + "iamcco/markdown-preview.nvim", + run = "cd app && npm install", + setup = function() + vim.g.mkdp_filetypes = { "markdown" } + end, + ft = { "markdown" }, + }) + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require("packer").sync() + end +end) diff --git a/.config/nvim/lua/user/session-manager.lua b/.config/nvim/lua/user/session-manager.lua new file mode 100644 index 0000000..b58609d --- /dev/null +++ b/.config/nvim/lua/user/session-manager.lua @@ -0,0 +1,8 @@ +local status_ok, session_manager = pcall(require, "session_manager") +if not status_ok then + return +end + +session_manager.setup({ + autosave_only_in_session = false, +}) diff --git a/.config/nvim/lua/user/telescope.lua b/.config/nvim/lua/user/telescope.lua new file mode 100644 index 0000000..4ce02b6 --- /dev/null +++ b/.config/nvim/lua/user/telescope.lua @@ -0,0 +1,42 @@ +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + return +end + +local actions = require("telescope.actions") + +telescope.setup({ + defaults = { + prompt_prefix = "> ", + selection_caret = " ", + path_display = { "smart" }, + file_ignore_patterns = { ".git/", "node_modules" }, + + mappings = { + i = { + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, + }, + }, + pickers = { + live_grep = { + additional_args = function() + return { "--hidden", "-g", "!.git/" } + end, + }, + }, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown({}), + }, + fzf = { + case_mode = "ignore_case", + }, + }, +}) + +telescope.load_extension("fzf") +telescope.load_extension("ui-select") diff --git a/.config/nvim/lua/user/treesitter.lua b/.config/nvim/lua/user/treesitter.lua new file mode 100644 index 0000000..a5762eb --- /dev/null +++ b/.config/nvim/lua/user/treesitter.lua @@ -0,0 +1,17 @@ +local status_ok, configs = pcall(require, "nvim-treesitter.configs") +if not status_ok then + return +end + +configs.setup({ + ensure_installed = "all", -- one of "all" or a list of languages + ignore_install = { "" }, -- List of parsers to ignore installing + highlight = { + enable = true, -- false will disable the whole extension + disable = { "css" }, -- list of language that will be disabled + }, + autopairs = { + enable = true, + }, + indent = { enable = true, disable = { "python", "css" } }, +}) diff --git a/.config/nvim/lua/user/trouble.lua b/.config/nvim/lua/user/trouble.lua new file mode 100644 index 0000000..f92d2cc --- /dev/null +++ b/.config/nvim/lua/user/trouble.lua @@ -0,0 +1,6 @@ +local status_ok, trouble = pcall(require, "trouble") +if not status_ok then + return +end + +trouble.setup({}) diff --git a/.config/nvim/lua/user/wilder.lua b/.config/nvim/lua/user/wilder.lua new file mode 100644 index 0000000..a2b2391 --- /dev/null +++ b/.config/nvim/lua/user/wilder.lua @@ -0,0 +1,67 @@ +local status_ok, wilder = pcall(require, "wilder") +if not status_ok then + return +end + +wilder.setup({ + modes = { ":" }, +}) + +wilder.set_option("use_python_remote_plugin", 1) + +wilder.set_option("pipeline", { + wilder.branch( + wilder.python_file_finder_pipeline({ + file_command = { "fd", "--hidden", "--type=file", "--exclude=.git" }, + dir_command = { "fd", "--hidden", "--type=directory", "--exclude=.git" }, + filters = { "fuzzy_filter", "difflib_sorter" }, + }), + wilder.cmdline_pipeline({ + fuzzy = 2, + fuzzy_filter = wilder.lua_fzy_filter(), + }) + ), +}) + +-- Better highlighting + +local gradient = { + "#f4468f", + "#fd4a85", + "#ff507a", + "#ff566f", + "#ff5e63", + "#ff6658", + "#ff704e", + "#ff7a45", + "#ff843d", + "#ff9036", + "#f89b31", + "#efa72f", + "#e6b32e", + "#dcbe30", + "#d2c934", + "#c8d43a", + "#bfde43", + "#b6e84e", + "#aff05b", +} + +for i, fg in ipairs(gradient) do + gradient[i] = wilder.make_hl("WilderGradient" .. i, "Pmenu", { { a = 1 }, { a = 1 }, { foreground = fg } }) +end + +wilder.set_option( + "renderer", + wilder.popupmenu_renderer({ + highlights = { + border = "Normal", + gradient = gradient, + }, + + border = "rounded", + highlighter = wilder.highlighter_with_gradient({ + wilder.lua_fzy_highlighter(), + }), + }) +) diff --git a/.config/polybar/scripts/polywins b/.config/polybar/scripts/polywins index fd3aec7..c727a0b 100755 --- a/.config/polybar/scripts/polywins +++ b/.config/polybar/scripts/polywins @@ -48,9 +48,9 @@ get_icon_by_name() { name=$(echo "$1" | tr '[:upper:]' '[:lower:]') declare -A ICON_MAP=( - [tilix]= [alacritty]= [kitty]= + [nvim]= [code]= [brave-browser]= [firefox]= @@ -76,6 +76,7 @@ get_icon_by_name() [spotify]= [telegramdesktop]= [xterm]= + [tilix]= ) if [ ${ICON_MAP[$name]+_} ]; then @@ -191,7 +192,7 @@ generate_window_list() { # Format each window name one by one # Space and . are both used as IFS, # because classname and class are separated by '.' - while IFS=" " read -r wid ws cname host title; do + while IFS=" " read -r wid ws cname _ title; do cname=${cname##*.} # Don't show the window if on another workspace (-1 = sticky) if [ "$ws" != "$active_workspace" ] && [ "$ws" != "-1" ]; then diff --git a/.vimrc b/.vimrc deleted file mode 100644 index dd6ab52..0000000 --- a/.vimrc +++ /dev/null @@ -1,14 +0,0 @@ -" Allow saving of files as sudo when I forgot to start vim using sudo. -cmap w!! w !sudo tee > /dev/null % - -syntax on - -" Use four spaces for indentation -set tabstop=4 -set shiftwidth=4 -set expandtab - -" Disable visual mode -set mouse-=a - -let mapleader="," diff --git a/.zshrc b/.zshrc index d6ee826..fc12559 100644 --- a/.zshrc +++ b/.zshrc @@ -42,6 +42,8 @@ alias k=kubectl alias icat="kitty +kitten icat --align=left" alias idiff="kitty +kitten diff" alias ls="ls --group-directories-first --color=auto --hyperlink=auto" +alias vim=nvim +alias neovim=nvim ##### Functions to be used from command line ##### @@ -79,8 +81,8 @@ fi ##### default apps ##### -export EDITOR='vim' -export VISUAL='vim' +export EDITOR='nvim' +export VISUAL='nvim' export PAGER='less' export BROWSER='/usr/bin/vivaldi-stable' diff --git a/README.md b/README.md new file mode 100644 index 0000000..96d54a8 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# Dot Files + +My dotfiles, including: + +- neovim +- kitty +- polybar +- zsh +- prezto conf for my [prezto fork](https://github.com/dcarrillo/prezto) +- p10k + +Unmaintained because I don't use them anymore: + +- tmux +- tilix (dconf) + +In addition to the dotfiles, some Gnome shell extension confs are included to make polybar and cli great again on Gnome. +