diff --git a/nvim/init.vim b/nvim/init.vim index bad7756..e3f9157 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -62,7 +62,6 @@ Plug 'tpope/vim-commentary' Plug 'tpope/vim-surround' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' -Plug 'itchyny/lightline.vim' Plug 'wakatime/vim-wakatime' Plug 'voldikss/vim-floaterm' Plug 'pechorin/any-jump.vim' @@ -70,8 +69,8 @@ Plug 'jiangmiao/auto-pairs' Plug 'ap/vim-css-color' Plug 'prettier/vim-prettier', { 'do': 'yarn install' } Plug 'sheerun/vim-polyglot' -Plug 'maximbaz/lightline-ale' Plug 'osyo-manga/vim-over' +Plug 'github/copilot.vim' " Plug 'dense-analysis/ale' " Plug 'neoclide/coc.nvim', {'branch': 'release'} @@ -80,12 +79,13 @@ if has('nvim') Plug 'akinsho/bufferline.nvim' " Plug 'chentau/marks.nvim' Plug 'folke/which-key.nvim' - Plug 'github/copilot.vim' Plug 'glepnir/dashboard-nvim' Plug 'kyazdani42/nvim-web-devicons' Plug 'kyazdani42/nvim-tree.lua' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'TimUntersberger/neogit' + Plug 'ojroques/nvim-lspfuzzy' + Plug 'nvim-lualine/lualine.nvim' Plug 'neovim/nvim-lspconfig' Plug 'williamboman/nvim-lsp-installer' @@ -99,7 +99,10 @@ if has('nvim') Plug 'onsails/lspkind-nvim' Plug 'saadparwaiz1/cmp_luasnip' Plug 'L3MON4D3/LuaSnip' + Plug 'rmagatti/goto-preview', + Plug 'folke/trouble.nvim' + Plug 'olimorris/onedarkpro.nvim' Plug 'NTBBloodbath/doom-one.nvim' Plug 'Mofiqul/dracula.nvim' Plug 'projekt0n/github-nvim-theme' @@ -109,6 +112,8 @@ else Plug 'mhinz/vim-startify' Plug 'preservim/nerdtree' | Plug 'Xuyuanp/nerdtree-git-plugin' Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] } + Plug 'itchyny/lightline.vim' + Plug 'maximbaz/lightline-ale' Plug 'joshdick/onedark.vim' Plug 'kaicataldo/material.vim', { 'branch': 'main' } @@ -127,14 +132,19 @@ if has('nvim') source ~/.config/nvim/plugin-confs/nvimtree.lua source ~/.config/nvim/plugin-confs/treesitter.lua source ~/.config/nvim/plugin-confs/neogit.lua + source ~/.config/nvim/plugin-confs/lspfuzzy.lua + source ~/.config/nvim/plugin-confs/lualine.lua set completeopt=menu,menuone,noselect + source ~/.config/nvim/plugin-confs/code_actions.lua source ~/.config/nvim/plugin-confs/lspconfig.lua source ~/.config/nvim/plugin-confs/lsp-signature.lua source ~/.config/nvim/plugin-confs/symbols-outline.lua source ~/.config/nvim/plugin-confs/null-ls.lua source ~/.config/nvim/plugin-confs/nvim-cmp.lua source ~/.config/nvim/plugin-confs/lsp-kind.lua + source ~/.config/nvim/plugin-confs/goto-preview.lua + source ~/.config/nvim/plugin-confs/trouble.lua source ~/.vim/plugin-confs/fzf.vim source ~/.vim/plugin-confs/vim-closetag.vim @@ -145,6 +155,7 @@ if has('nvim') source ~/.config/nvim/plugin-confs/doomone.lua source ~/.config/nvim/plugin-confs/dracula.lua source ~/.config/nvim/plugin-confs/github-theme.lua + source ~/.config/nvim/plugin-confs/onedarkpro.lua " makes fzf match colorscheme (I think) augroup fzf_preview @@ -239,4 +250,8 @@ command! Aniwrapper execute ":FloatermNew aniwrapper -qtdoomone -D 144" "------------------------------------------------------------------------------ let g:mapleader = "\" let g:maplocalleader = ',' -source ~/.vim/keybindings.vim +if has('nvim') + source ~/.config/nvim/keybindings.vim +else + source ~/.vim/keybindings.vim +endif diff --git a/nvim/keybindings.vim b/nvim/keybindings.vim new file mode 100644 index 0000000..3cb90ad --- /dev/null +++ b/nvim/keybindings.vim @@ -0,0 +1,97 @@ +" KEYBINDINGS +" imap +nmap :set paste!set paste? +nmap :! +" nmap :NERDTreeToggle +nmap :NvimTreeToggle +" nnoremap :wa:vertical botright term ++kill=term +nmap Q !!$SHELL + +" reselect visual selection after indent +vnoremap < >gv + +" open file under cursor, create if necessary +nnoremap gF :edit + +" fzf +nnoremap // :Lines +nnoremap ?? :BLines + +" aniwrapper/ani-cli (until i find better use for a keys) +nmap as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144 +nmap ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144 +" buffers +" nmap bB :CocCommand fzf-preview.AllBuffers +nmap bb :Buffers +nmap bk :bdelete +nmap bn :bnext +nmap bp :bprev +nmap :bnext +nmap :bprev +nmap cd :LspDiagnostics +" git +nmap gc :CocCommand fzf-preview.GitLogs +nmap gf :GitFiles +if has('nvim') + nmap gg :Neogit +else + nmap gg :FloatermNew --title=lazygit --opener=vsplit --width=1.0 --height=1.0 lazygit +endif +" nmap gs :CocCommand fzf-preview.GitStatus +" nmap gr :CocCommand fzf-preview.CocReferences +nnoremap gpc lua require('goto-preview').close_all_win() +nnoremap gpd lua require('goto-preview').goto_preview_definition() +nnoremap gpi lua require('goto-preview').goto_preview_implementation() +nnoremap gP lua require('goto-preview').close_all_win() +nnoremap gR TroubleToggle lsp_references +" Only set if you have telescope installed +" nnoremap gpr lua require('goto-preview').goto_preview_references() +" help/history +nmap hc :Commands +nmap hk :Maps +" insert snippets +nmap isp :-1read $HOME/Templates/python.py4jw +" any jump plugin +nmap j :AnyJump +nmap n :NvimTreeToggle +" toggle/open +nmap ob :FloatermNew --title=bpytop --opener=vsplit bpytop +nmap od :FloatermNew --title=lazydocker --opener=vsplit lazydocker +nmap on :FloatermNew --title=ncmpcpp --opener=vsplit ncmpcpp +nmap oo :OverCommandLine +nmap or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD" +" nmap ot :vertical botright ter ++kill=terminal ++close +nmap ot :FloatermNew --title=floaterm --name=vsplit-term --wintype=vsplit --position=botright --width=0.5 +" refresh nvimtree for now +nmap r :NvimTreeRefresh +" search +nmap sc :nohls +nmap sf :Files +nmap sF :AllFiles +" toggle coc outline +nmap to :SymbolsOutline +" terminal +nmap tt :FloatermToggle vsplit-term +nmap :wa:FloatermToggle floatingterm +" for toggling/hiding the vsplit-term +tnoremap tt :FloatermToggle vsplit-term +tnoremap :FloatermToggle floatingterm +tnoremap + +nnoremap xx TroubleToggle +nnoremap xw TroubleToggle workspace_diagnostics +nnoremap xd TroubleToggle document_diagnostics +nnoremap xq TroubleToggle quickfix +nnoremap xl TroubleToggle loclist + +nmap ss :SessionSave +nmap sl :SessionLoad +nnoremap fh :DashboardFindHistory +" search fzf, refs, impls, defs +nmap ff :CocCommand fzf-preview.ProjectFiles +" nnoremap ff :DashboardFindFile +nnoremap tc :DashboardChangeColorscheme +nnoremap fa :DashboardFindWord +nnoremap fb :DashboardJumpMark +nnoremap cn :DashboardNewFile diff --git a/nvim/plugin-confs/catppuccin.lua b/nvim/plugin-confs/catppuccin.lua new file mode 100644 index 0000000..93e32ca --- /dev/null +++ b/nvim/plugin-confs/catppuccin.lua @@ -0,0 +1,61 @@ +local catppuccin = require("catppuccin") + +local settings = { + transparent_background = false, + term_colors = false, + styles = { + comments = "italic", + functions = "italic", + keywords = "italic", + strings = "NONE", + variables = "italic", + }, + integrations = { + treesitter = true, + native_lsp = { + enabled = true, + virtual_text = { + errors = "italic", + hints = "italic", + warnings = "italic", + information = "italic", + }, + underlines = { + errors = "underline", + hints = "underline", + warnings = "underline", + information = "underline", + }, + }, + lsp_trouble = false, + cmp = true, + lsp_saga = false, + gitgutter = false, + gitsigns = true, + telescope = true, + nvimtree = { + enabled = true, + show_root = false, + transparent_panel = false, + }, + which_key = false, + indent_blankline = { + enabled = true, + colored_indent_levels = false, + }, + dashboard = true, + neogit = false, + vim_sneak = false, + fern = false, + barbar = false, + bufferline = true, + markdown = true, + lightspeed = false, + ts_rainbow = false, + hop = false, + notify = true, + telekasten = true, + } +} + +catppuccin.setup(settings) diff --git a/nvim/plugin-confs/code_actions.lua b/nvim/plugin-confs/code_actions.lua new file mode 100644 index 0000000..1d24ff5 --- /dev/null +++ b/nvim/plugin-confs/code_actions.lua @@ -0,0 +1,14 @@ +local M = {} + +local lsp_util = vim.lsp.util + +function M.code_action_listener() + local context = { diagnostics = vim.lsp.diagnostic.get_line_diagnostics() } + local params = lsp_util.make_range_params() + params.context = context + vim.lsp.buf_request(0, 'textDocument/codeAction', params, function(err, _, result) + -- do something with result - e.g. check if empty and show some indication such as a sign + end) +end + +return M diff --git a/nvim/plugin-confs/goto-preview.lua b/nvim/plugin-confs/goto-preview.lua new file mode 100644 index 0000000..2bbc509 --- /dev/null +++ b/nvim/plugin-confs/goto-preview.lua @@ -0,0 +1,18 @@ +require('goto-preview').setup { + width = 120; -- Width of the floating window + height = 15; -- Height of the floating window + border = {"↖", "─" ,"┐", "│", "┘", "─", "└", "│"}; -- Border characters of the floating window + default_mappings = false; -- Bind default mappings + debug = false; -- Print debug information + opacity = nil; -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false; -- Binds arrow keys to resizing the floating window. + post_open_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + references = { -- Configure the telescope UI for slowing the references cycling window. + -- telescope = telescope.themes.get_dropdown({ hide_preview = false }) + }; + -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. + focus_on_open = true; -- Focus the floating window when opening it. + dismiss_on_move = false; -- Dismiss the floating window when moving the cursor. + force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden +} diff --git a/nvim/plugin-confs/lspfuzzy.lua b/nvim/plugin-confs/lspfuzzy.lua new file mode 100644 index 0000000..a80ac36 --- /dev/null +++ b/nvim/plugin-confs/lspfuzzy.lua @@ -0,0 +1,16 @@ +require('lspfuzzy').setup { + methods = 'all', -- either 'all' or a list of LSP methods (see below) + jump_one = true, -- jump immediately if there is only one location + save_last = false, -- save last location results for the :LspFuzzyLast command + callback = nil, -- callback called after jumping to a location + fzf_preview = { -- arguments to the FZF '--preview-window' option + 'right:+{2}-/2' -- preview on the right and centered on entry + }, + fzf_action = { -- FZF actions + ['ctrl-t'] = 'tab split', -- go to location in a new tab + ['ctrl-v'] = 'vsplit', -- go to location in a vertical split + ['ctrl-x'] = 'split', -- go to location in a horizontal split + }, + fzf_modifier = ':~:.', -- format FZF entries, see |filename-modifiers| + fzf_trim = false, -- trim FZF entries +} diff --git a/nvim/plugin-confs/lualine.lua b/nvim/plugin-confs/lualine.lua new file mode 100644 index 0000000..fa0c9e2 --- /dev/null +++ b/nvim/plugin-confs/lualine.lua @@ -0,0 +1,52 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'codedark', + -- theme = 'dracula', + -- theme = 'horizon', + -- theme = 'onedark', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = {}, + always_divide_middle = true, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = {'branch', 'diff'}, + lualine_c = {'filename'}, + lualine_x = { + { + 'diagnostics', + 'fileformat', + symbols = { + unix = '', -- e712 + dos = '', -- e70f + mac = '', -- e711 + } + }, 'encoding', 'fileformat', {'filetype', colored=true, icon_only=false}}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + { + 'filename', + file_status = true, -- Displays file status (readonly status, modified status) + path = 0, -- 0: Just the filename + shorting_target = 40, -- Shortens path to leave 40 spaces in the window + symbols = { + modified = '[+]', -- Text to show when the file is modified. + readonly = '[-]', -- Text to show when the file is non-modifiable or readonly. + unnamed = '[No Name]', -- Text to show for unnamed buffers. + } + }, + }, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = {'quickfix', 'fzf', 'nvim-tree', 'symbols-outline', 'fugitive'} +} diff --git a/nvim/plugin-confs/null-ls.lua b/nvim/plugin-confs/null-ls.lua index f19140b..78cecbd 100644 --- a/nvim/plugin-confs/null-ls.lua +++ b/nvim/plugin-confs/null-ls.lua @@ -2,17 +2,6 @@ local null_ls = require("null-ls") local helpers = require("null-ls.helpers") require("null-ls").setup({ - sources = { - require("null-ls").builtins.formatting.stylua, - require("null-ls").builtins.diagnostics.eslint, - require("null-ls").builtins.completion.spell, - require("null-ls").builtins.formatting.shfmt.with({ - extra_args = { "-i", "4", "-ci", "-sr" } - }), - require("null-ls").builtins.diagnostics.shellcheck.with({ - extra_args = { "-s", "bash", "-o", "check-extra-masked-returns, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables" } - }) - }, on_attach = function(client) if client.resolved_capabilities.document_formatting then vim.cmd([[ @@ -23,45 +12,56 @@ require("null-ls").setup({ ]]) end end, + sources = { + require("null-ls").builtins.completion.spell, + require("null-ls").builtins.formatting.shfmt.with({ + filetypes = {"sh", "bash"}, + extra_args = { "-i", "4", "-ci", "-sr" } + }), + require("null-ls").builtins.code_actions.shellcheck, + require("null-ls").builtins.diagnostics.shellcheck.with({ + extra_args = { "--format", "json1", "--source-path=$DIRNAME", "--external-sources", "-", "-s", "bash", "-o", "check-extra-masked-returns, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables" } + }), + }, }) -local markdownlint = { - method = null_ls.methods.DIAGNOSTICS, - filetypes = { "markdown" }, - -- null_ls.generator creates an async source - -- that spawns the command with the given arguments and options - generator = null_ls.generator({ - command = "markdownlint", - args = { "--stdin" }, - to_stdin = true, - from_stderr = true, - -- choose an output format (raw, json, or line) - format = "line", - check_exit_code = function(code, stderr) - local success = code <= 1 +-- local markdownlint = { +-- method = null_ls.methods.DIAGNOSTICS, +-- filetypes = { "markdown" }, +-- -- null_ls.generator creates an async source +-- -- that spawns the command with the given arguments and options +-- generator = null_ls.generator({ +-- command = "markdownlint", +-- args = { "--stdin" }, +-- to_stdin = true, +-- from_stderr = true, +-- -- choose an output format (raw, json, or line) +-- format = "line", +-- check_exit_code = function(code, stderr) +-- local success = code <= 1 - if not success then - -- can be noisy for things that run often (e.g. diagnostics), but can - -- be useful for things that run on demand (e.g. formatting) - print(stderr) - end +-- if not success then +-- -- can be noisy for things that run often (e.g. diagnostics), but can +-- -- be useful for things that run on demand (e.g. formatting) +-- print(stderr) +-- end - return success - end, - -- use helpers to parse the output from string matchers, - -- or parse it manually with a function - on_output = helpers.diagnostics.from_patterns({ - { - pattern = [[:(%d+):(%d+) [%w-/]+ (.*)]], - groups = { "row", "col", "message" }, - }, - { - pattern = [[:(%d+) [%w-/]+ (.*)]], - groups = { "row", "message" }, - }, - }), - }), -} +-- return success +-- end, +-- -- use helpers to parse the output from string matchers, +-- -- or parse it manually with a function +-- on_output = helpers.diagnostics.from_patterns({ +-- { +-- pattern = [[:(%d+):(%d+) [%w-/]+ (.*)]], +-- groups = { "row", "col", "message" }, +-- }, +-- { +-- pattern = [[:(%d+) [%w-/]+ (.*)]], +-- groups = { "row", "message" }, +-- }, +-- }), +-- }), +-- } -- local shellcheck = { -- method = null_ls.methods.DIAGNOSTICS, @@ -95,5 +95,5 @@ local markdownlint = { -- }), -- } -null_ls.register(markdownlint) +-- null_ls.register(markdownlint) -- null_ls.register(shellcheck) diff --git a/nvim/plugin-confs/nvim-cmp.lua b/nvim/plugin-confs/nvim-cmp.lua index a569c92..32c0360 100644 --- a/nvim/plugin-confs/nvim-cmp.lua +++ b/nvim/plugin-confs/nvim-cmp.lua @@ -40,24 +40,24 @@ cmp.setup({ behavior = cmp.ConfirmBehavior.Replace, select = true, }, - [''] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, - [''] = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, + -- [''] = function(fallback) + -- if cmp.visible() then + -- cmp.select_next_item() + -- elseif luasnip.expand_or_jumpable() then + -- luasnip.expand_or_jump() + -- else + -- fallback() + -- end + -- end, + -- [''] = function(fallback) + -- if cmp.visible() then + -- cmp.select_prev_item() + -- elseif luasnip.jumpable(-1) then + -- luasnip.jump(-1) + -- else + -- fallback() + -- end + -- end, }, formatting = { format = lspkind.cmp_format({ diff --git a/nvim/plugin-confs/onedarkpro.lua b/nvim/plugin-confs/onedarkpro.lua new file mode 100644 index 0000000..abe8859 --- /dev/null +++ b/nvim/plugin-confs/onedarkpro.lua @@ -0,0 +1,38 @@ +local onedarkpro = require("onedarkpro") +onedarkpro.setup({ + -- Theme can be overwritten with 'onedark' or 'onelight' as a string! + -- theme = function() + -- if vim.o.background == "dark" then + -- return "onedark" + -- else + -- return "onelight" + -- end + -- end, + theme = "onedark", + colors = {}, -- Override default colors. Can specify colors for "onelight" or "onedark" themes by passing in a table + hlgroups = {}, -- Override default highlight groups + plugins = { -- Override which plugins highlight groups are loaded + native_lsp = true, + polygot = true, + treesitter = true, + -- Others omitted for brevity + }, + styles = { + comments = "italic", + functions = "bold", + keywords = "bold,italic", + strings = "italic", + variables = "bold" + }, + options = { + bold = true, -- Use the themes opinionated bold styles? + italic = true, -- Use the themes opinionated italic styles? + underline = false, -- Use the themes opinionated underline styles? + undercurl = false, -- Use the themes opinionated undercurl styles? + cursorline = false, -- Use cursorline highlighting? + transparency = false, -- Use a transparent background? + terminal_colors = true, -- Use the theme's colors for Neovim's :terminal? + window_unfocussed_color = false, -- When the window is out of focus, change the normal background? + } +}) +onedarkpro.load() diff --git a/nvim/plugin-confs/tokyodark.lua b/nvim/plugin-confs/tokyodark.lua new file mode 100644 index 0000000..a6c5cfd --- /dev/null +++ b/nvim/plugin-confs/tokyodark.lua @@ -0,0 +1,5 @@ +vim.g.tokyodark_transparent_background = false +vim.g.tokyodark_enable_italic_comment = true +vim.g.tokyodark_enable_italic = true +vim.g.tokyodark_color_gamma = "1.0" +vim.cmd("colorscheme tokyodark") diff --git a/nvim/plugin-confs/trouble.lua b/nvim/plugin-confs/trouble.lua new file mode 100644 index 0000000..783c70c --- /dev/null +++ b/nvim/plugin-confs/trouble.lua @@ -0,0 +1,47 @@ +require("trouble").setup { + position = "bottom", -- position of the list can be: bottom, top, left, right + height = 10, -- height of the trouble list when position is top or bottom + width = 50, -- width of the list when position is left or right + icons = true, -- use devicons for filenames + mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" + fold_open = "", -- icon used for open folds + fold_closed = "", -- icon used for closed folds + group = true, -- group results by file + padding = true, -- add an extra new line on top of the list + 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 = {"", ""}, -- 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 = {"o"}, -- 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", -- preview item + next = "j" -- next item + }, + indent_lines = true, -- add an indent guide below the fold icons + auto_open = false, -- automatically open the list when you have diagnostics + auto_close = false, -- automatically close the list when you have no diagnostics + auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window + auto_fold = false, -- automatically fold a file trouble list at creation + auto_jump = {"lsp_definitions"}, -- for the given modes, automatically jump if there is only a single result + signs = { + -- icons / text used for a diagnostic + error = "", + warning = "", + hint = "", + information = "", + other = "﫠" + }, + use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client +}