diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..be2196a --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +# Compiled Lua sources +luac.out + +# luarocks build files +*.src.rock +*.zip +*.tar.gz + +# Object files +*.o +*.os +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo +*.def +*.exp + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + + +plugin/packer_compiled.lua +java-debug/ +vscode-java-test/ \ No newline at end of file diff --git a/init.lua b/init.lua index ef36a6c..4afa710 100644 --- a/init.lua +++ b/init.lua @@ -1,173 +1,22 @@ -vim.opt.syntax = 'on' -vim.cmd("filetype plugin indent on") -vim.opt.number = true --- set relativenumber -vim.opt.relativenumber = false ---vim.opt.path += "**" -vim.opt.swapfile = false -vim.opt.wildmenu = true -vim.opt.backspace = "indent,eol,start" -vim.opt.undodir = "/home/ateijelo/.cache/nvim/undo" -vim.opt.undofile = true -vim.opt.incsearch = true -vim.opt.smartindent = true -vim.opt.ic = true --- set colorcolumn=88 -vim.opt.et = true -vim.opt.ts = 4 -vim.opt.sw = 4 ---set showmatch -vim.opt.hlsearch = true ---incsearch -vim.cmd("highlight ColorColumn ctermbg=9") -vim.cmd("autocmd FileType yaml,yaml.ansible setlocal indentkeys-=0#") - --- don't use NeoVim's thin cursor -vim.opt.guicursor = "" - -vim.o.mouse = "" - -require('plugins') -require("colorschemes") - -vim.cmd("hi MatchParen cterm=bold,underline gui=bold,underline") - ---vim.api.nvim_set_keymap("n", "", "", { noremap = true }) -vim.g.mapleader = " " - -vim.api.nvim_set_keymap("n", "bc", "BufferLinePickClose", { noremap = true, silent = true }) - ---local harpoon_ui = require("harpoon.ui") ---local harpoon_mark = require("harpoon.mark") ---vim.keymap.set("n", '', harpoon_ui.toggle_quick_menu) -for _, mode in ipairs({"n", "i", "v"}) do - vim.keymap.set(mode, '', "BufferLineGoToBuffer 1", { noremap = true, silent = true }) - vim.keymap.set(mode, '', "BufferLineGoToBuffer 2", { noremap = true, silent = true }) - vim.keymap.set(mode, '', "BufferLineGoToBuffer 3", { noremap = true, silent = true }) - vim.keymap.set(mode, '', "BufferLineGoToBuffer 4", { noremap = true, silent = true }) - vim.keymap.set(mode, '', "BufferLineGoToBuffer 5", { noremap = true, silent = true }) -end - -for _, mode in ipairs({"n", "v"}) do - vim.api.nvim_set_keymap(mode, "", "g", { noremap = true }) - vim.api.nvim_set_keymap(mode, "", "g", { noremap = true }) - vim.api.nvim_set_keymap(mode, "", "", { noremap = true }) - vim.api.nvim_set_keymap(mode, "", "", { noremap = true }) - vim.api.nvim_set_keymap(mode, "", "", { noremap = true }) - vim.api.nvim_set_keymap(mode, "", "", { noremap = true }) -end - -vim.api.nvim_set_keymap('v', "", ":MoveBlock(1)", { noremap = true }) -vim.api.nvim_set_keymap('v', "", ":MoveBlock(-1)", { noremap = true }) - -vim.api.nvim_set_keymap("n", "lj", "lua vim.diagnostic.open_float()", { noremap = true }) ---vim.api.nvim_set_keymap("n", "", "lua vim.diagnostic.open_float()", { noremap = true }) -vim.api.nvim_set_keymap("n", "la", "lua vim.lsp.buf.code_action()", { noremap = true, silent = true }) ---vim.api.nvim_set_keymap("n", "", "lua vim.lsp.buf.code_action()", { noremap = true }) - -require('telescope').setup({ - initial_mode = "normal" -}) -local builtin = require('telescope.builtin') -vim.keymap.set('n', 'p', builtin.find_files, {}) - --- toggle numbers and diagnostics with Alt+N -vim.keymap.set( - "n", - "", - function() - vim.o.number = not vim.o.number; - if not vim.diagnostic.get_next() then return end - if vim.o.number then - vim.diagnostic.show() - else - vim.diagnostic.hide() - end - end -) - - --- require'lspconfig'.pyright.setup{} -local nvim_lsp = require'lspconfig' -nvim_lsp.pyright.setup{} - --- local on_attach = function(client) --- require'completion'.on_attach(client) --- end - - --- require('snippy').setup({ --- mappings = { --- is = { --- [''] = 'expand_or_advance', --- [''] = 'previous', --- }, --- nx = { --- ['x'] = 'cut_text', --- }, --- }, --- }) - -require('completion') - -local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -nvim_lsp.rust_analyzer.setup({ - capabilities = capabilities, - settings = { - ["rust-analyzer"] = { - } - } -}) - -vim.diagnostic.config({ - underline = true, - signs = true, - virtual_text = true, - float = { - show_header = true, - source = 'if_many', - border = 'rounded', - focusable = false, - } -}) - -require('treesitter') - -require('nvim_comment').setup() ---vim.keymap.set('v', '', "'<,'>CommentToggle") -vim.keymap.set('v', '', "'<,'>CommentToggle") -vim.keymap.set('n', '', "CommentToggle") ---vim.keymap.set('n', '', "CommentToggle") - --- hover on K -vim.keymap.set('n', 'K', vim.lsp.buf.hover) --- Change border of documentation hover window, See https://github.com/neovim/neovim/pull/13998. -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = "rounded", -}) - --- format on save ---vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] - --- require('nvim-tree').setup() - -require('exrc').setup() -require('bufferline').setup() - -vim.cmd [[ -fu! SaveSession() - if filereadable(getcwd() . '/.session.vim') - execute 'mksession! ' . getcwd() . '/.session.vim' - endif -endfunction - -fu! RestoreSession() - if filereadable(getcwd() . '/.session.vim') - execute 'so ' . getcwd() . '/.session.vim' - endif -endfunction - -autocmd VimLeavePre * call SaveSession() -"autocmd VimEnter * nested call RestoreSession() -]] - +require "user.options" +require "user.keymaps" +require "user.plugins" +require "user.autocommands" +require "user.colorscheme" +require "user.cmp" +require "user.telescope" +require "user.gitsigns" +require "user.treesitter" +require "user.autopairs" +require "user.comment" +require "user.nvim-tree" +require "user.bufferline" +require "user.lualine" +require "user.toggleterm" +require "user.project" +require "user.impatient" +require "user.illuminate" +require "user.indentline" +require "user.alpha" +require "user.lsp" +require "user.dap" diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua deleted file mode 100644 index 288b0a7..0000000 --- a/lua/colorschemes.lua +++ /dev/null @@ -1,79 +0,0 @@ -function onedarkpro() - require("onedarkpro").setup({ - theme = "onedark_dark", - styles = { -- Choose from "bold,italic,underline" - strings = "NONE", -- Style that is applied to strings. - comments = "italic", -- Style that is applied to comments - keywords = "bold", -- Style that is applied to keywords - functions = "NONE", -- Style that is applied to functions - variables = "NONE", -- Style that is applied to variables - virtual_text = "NONE", -- Style that is applied to virtual text - }, - options = { - bold = true, -- Use the colorscheme's opinionated bold styles? - italic = true, -- Use the colorscheme's opinionated italic styles? - underline = true, -- Use the colorscheme's opinionated underline styles? - undercurl = true, -- Use the colorscheme's opinionated undercurl styles? - cursorline = false, -- Use cursorline highlighting? - transparency = false, -- Use a transparent background? - terminal_colors = false, -- Use the colorscheme's colors for Neovim's :terminal? - window_unfocussed_color = true, -- When the window is out of focus, change the normal background? - } - }) - vim.cmd([[colorscheme onedarkpro]]) -end - -function nightfox() - local ok, nf = pcall(require, 'nightfox') - if not ok then - return - end - nf.setup({ - options = { - -- -- Compiled file's destination location - -- compile_path = vim.fn.stdpath("cache") .. "/nightfox", - -- compile_file_suffix = "_compiled", -- Compiled file suffix - -- transparent = false, -- Disable setting background - -- terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal` - -- dim_inactive = false, -- Non focused panes set to alternative background - styles = { -- Style to be applied to different syntax groups - comments = "italic", -- Value is any valid attr-list value `:help attr-list` - -- conditionals = "NONE", - -- constants = "NONE", - -- functions = "NONE", - -- keywords = "NONE", - -- numbers = "NONE", - -- operators = "NONE", - -- strings = "NONE", - -- types = "NONE", - -- variables = "NONE", - }, - -- inverse = { -- Inverse highlight for different types - -- match_paren = false, - -- visual = false, - -- search = false, - -- }, - }, - palettes = {}, - specs = {}, - groups = {}, - }) - vim.cmd("colorscheme carbonfox") -end - -function catppuccin() - vim.g.catppuccin_flavour = "mocha" -- latte, frappe, macchiato, mocha - require("catppuccin").setup() - vim.cmd [[colorscheme catppuccin]] -end - -function setup() - --vim.g.tokyonight_style = "night" - --vim.cmd([[colorscheme tokyonight]]) - --vim.cmd([[colorscheme PaperColor]]) - --vim.cmd([[colorscheme moonfly]]) - --nightfox() - catppuccin() -end - -setup() diff --git a/lua/completion.lua b/lua/completion.lua deleted file mode 100644 index 91ceb5f..0000000 --- a/lua/completion.lua +++ /dev/null @@ -1,63 +0,0 @@ -local cmp = require'cmp' -local snippy = require('snippy') - -cmp.setup({ - - snippet = { - expand = function(args) - snippy.expand_snippet(args.body) - end - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - -- Accept currently selected 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 snippy.can_expand_or_advance() then - snippy.expand_or_advance() - else - fallback() - end - end, { "i", "s" }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif snippy.can_jump(-1) then - snippy.previous() - else - fallback() - end - end, { "i", "s" }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'snippy' }, - { name = 'buffer' }, - }), - formatting = { - fields = { - cmp.ItemField.Abbr, - cmp.ItemField.Kind, - cmp.ItemField.Menu, - }, - format = function(entry, vim_item) - vim_item.abbr = string.sub(vim_item.abbr, 1, 20) - vim_item.kind = string.sub(vim_item.kind, 1, 10) - if vim_item.menu then - vim_item.menu = string.sub(vim_item.menu, 1, 10) - end - return vim_item - end - } -}) - diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index 653c126..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,44 +0,0 @@ - -vim.cmd [[packadd packer.nvim]] - -local packer = require('packer') -packer.startup( - function(use) - use 'wbthomason/packer.nvim' - use 'neovim/nvim-lspconfig' - use 'mg979/vim-visual-multi' - use 'farmergreg/vim-lastplace' - use 'hrsh7th/cmp-nvim-lsp' - use 'hrsh7th/nvim-cmp' - use 'dcampos/nvim-snippy' - use 'dcampos/cmp-snippy' - use 'folke/tokyonight.nvim' - use 'fedepujol/move.nvim' - use { "catppuccin/nvim", as = "catppuccin" } --- use 'bluz71/vim-moonfly-colors' --- use 'NLKNguyen/papercolor-theme' --- use 'olimorris/onedarkpro.nvim' --- use 'EdenEast/nightfox.nvim' - use { - 'nvim-treesitter/nvim-treesitter', - run = function() - require('nvim-treesitter.install').update({ with_sync = true }) - end, - } - use { - 'nvim-telescope/telescope.nvim', tag = '0.1.0', - requires = { {'nvim-lua/plenary.nvim'} } - } - use 'ThePrimeagen/harpoon' - use 'terrortylor/nvim-comment' - use 'MunifTanjim/exrc.nvim' - use { 'akinsho/bufferline.nvim', tag = "v2.*", requires = 'kyazdani42/nvim-web-devicons' } - --use { - -- 'kyazdani42/nvim-tree.lua', - -- --requires = { - -- -- 'kyazdani42/nvim-web-devicons', -- optional, for file icons - -- --}, - -- --tag = 'nightly' -- optional, updated every week. (see issue #1193) - --} - end -) diff --git a/lua/treesitter.lua b/lua/treesitter.lua deleted file mode 100644 index 50c8e9e..0000000 --- a/lua/treesitter.lua +++ /dev/null @@ -1,43 +0,0 @@ -require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" - ensure_installed = { "rust" }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- Automatically install missing parsers when entering buffer - auto_install = true, - - -- List of parsers to ignore installing (for "all") - ignore_install = { "javascript" }, - - ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) - -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! - - highlight = { - -- `false` will disable the whole extension - enable = true, - - -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to - -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is - -- the name of the parser) - -- list of language that will be disabled - --disable = { "c", "rust" }, - - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, - - textobjects = { - lsp_interop = { - enable = true, - peek_definition_code = { - ["df"] = "@function.outer", - ["dF"] = "@class.outer", - }, - }, - }, -} diff --git a/lua/user/alpha.lua b/lua/user/alpha.lua new file mode 100644 index 0000000..9fe9d2f --- /dev/null +++ b/lua/user/alpha.lua @@ -0,0 +1,35 @@ +local status_ok, alpha = pcall(require, "alpha") +if not status_ok then + return +end + +local dashboard = require "alpha.themes.dashboard" +dashboard.section.header.val = { + [[ __ ]], + [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], + [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], + [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], + [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], + [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], +} +dashboard.section.buttons.val = { + dashboard.button("f", " " .. " Find file", ":Telescope find_files "), + dashboard.button("e", " " .. " New file", ":ene startinsert "), + dashboard.button("p", " " .. " Find project", ":lua require('telescope').extensions.projects.projects()"), + dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles "), + dashboard.button("t", " " .. " Find text", ":Telescope live_grep "), + dashboard.button("c", " " .. " Config", ":e ~/.config/nvim/init.lua "), + dashboard.button("q", " " .. " Quit", ":qa"), +} +local function footer() + return "chrisatmachine.com" +end + +dashboard.section.footer.val = footer() + +dashboard.section.footer.opts.hl = "Type" +dashboard.section.header.opts.hl = "Include" +dashboard.section.buttons.opts.hl = "Keyword" + +dashboard.opts.opts.noautocmd = true +alpha.setup(dashboard.opts) diff --git a/lua/user/autocommands.lua b/lua/user/autocommands.lua new file mode 100644 index 0000000..6f875dd --- /dev/null +++ b/lua/user/autocommands.lua @@ -0,0 +1,71 @@ +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "qf", "help", "man", "lspinfo", "spectre_panel" }, + callback = function() + vim.cmd([[ + nnoremap q :close + set nobuflisted + ]]) + end, +}) + +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "gitcommit"}, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + + +vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif") +-- vim.api.nvim_create_autocmd({ "BufEnter" }, { +-- callback = function() +-- vim.cmd [[ +-- if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif +-- ]] +-- end, +-- }) + +vim.api.nvim_create_autocmd({ "VimResized" }, { + callback = function() + vim.cmd("tabdo wincmd =") + end, +}) + +vim.api.nvim_create_autocmd({ "CmdWinEnter" }, { + callback = function() + vim.cmd("quit") + end, +}) +vim.api.nvim_create_autocmd({ "BufWinEnter" }, { + callback = function() + vim.cmd("set formatoptions-=cro") + end, +}) + +vim.api.nvim_create_autocmd({ "TextYankPost" }, { + callback = function() + vim.highlight.on_yank({ higroup = "Visual", timeout = 200 }) + end, +}) + +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + pattern = { "*.java" }, + callback = function() + vim.lsp.codelens.refresh() + end, +}) + +vim.api.nvim_create_autocmd({ "VimEnter" }, { + callback = function() + vim.cmd("hi link illuminatedWord LspReferenceText") + end, +}) diff --git a/lua/user/autopairs.lua b/lua/user/autopairs.lua new file mode 100644 index 0000000..8364c79 --- /dev/null +++ b/lua/user/autopairs.lua @@ -0,0 +1,34 @@ +-- 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" }, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + + fast_wrap = { + map = "", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, +}) + +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/lua/user/bufferline.lua b/lua/user/bufferline.lua new file mode 100644 index 0000000..f22fbcb --- /dev/null +++ b/lua/user/bufferline.lua @@ -0,0 +1,103 @@ +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 = "NvimTree", 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='LspDiagnosticsDefaultError'}, + 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/lua/user/cmp.lua b/lua/user/cmp.lua new file mode 100644 index 0000000..1eb816b --- /dev/null +++ b/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/lua/user/colorscheme.lua b/lua/user/colorscheme.lua new file mode 100644 index 0000000..881eba5 --- /dev/null +++ b/lua/user/colorscheme.lua @@ -0,0 +1,6 @@ +local colorscheme = "tokyonight-night" + +local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) +if not status_ok then + return +end diff --git a/lua/user/comment.lua b/lua/user/comment.lua new file mode 100644 index 0000000..da49998 --- /dev/null +++ b/lua/user/comment.lua @@ -0,0 +1,29 @@ +local status_ok, comment = pcall(require, "Comment") +if not status_ok then + return +end + +comment.setup({ + pre_hook = function(ctx) + -- Only calculate commentstring for tsx filetypes + if vim.bo.filetype == "typescriptreact" then + local U = require("Comment.utils") + + -- Determine whether to use linewise or blockwise commentstring + local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" + + -- Determine the location where to calculate commentstring from + local location = nil + if ctx.ctype == U.ctype.blockwise 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 = type, + location = location, + }) + end + end, +}) diff --git a/lua/user/dap.lua b/lua/user/dap.lua new file mode 100644 index 0000000..2ee829e --- /dev/null +++ b/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 { + 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/lua/user/gitsigns.lua b/lua/user/gitsigns.lua new file mode 100644 index 0000000..9453e4f --- /dev/null +++ b/lua/user/gitsigns.lua @@ -0,0 +1,36 @@ +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" }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, +} diff --git a/lua/user/illuminate.lua b/lua/user/illuminate.lua new file mode 100644 index 0000000..b9e814e --- /dev/null +++ b/lua/user/illuminate.lua @@ -0,0 +1,38 @@ +local status_ok, illuminate = pcall(require, "illuminate") +if not status_ok then + return +end + +vim.g.Illuminate_ftblacklist = {'alpha', 'NvimTree'} +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}) + +illuminate.configure { + providers = { + "lsp", + "treesitter", + "regex", + }, + delay = 200, + filetypes_denylist = { + "dirvish", + "fugitive", + "alpha", + "NvimTree", + "packer", + "neogitstatus", + "Trouble", + "lir", + "Outline", + "spectre_panel", + "toggleterm", + "DressingSelect", + "TelescopePrompt", + }, + filetypes_allowlist = {}, + modes_denylist = {}, + modes_allowlist = {}, + providers_regex_syntax_denylist = {}, + providers_regex_syntax_allowlist = {}, + under_cursor = true, +} diff --git a/lua/user/impatient.lua b/lua/user/impatient.lua new file mode 100644 index 0000000..84419e0 --- /dev/null +++ b/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/lua/user/indentline.lua b/lua/user/indentline.lua new file mode 100644 index 0000000..b7389d9 --- /dev/null +++ b/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/lua/user/keymaps.lua b/lua/user/keymaps.lua new file mode 100644 index 0000000..7b9bddb --- /dev/null +++ b/lua/user/keymaps.lua @@ -0,0 +1,80 @@ +-- 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) + +-- 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) + +-- Plugins -- + +-- NvimTree +keymap("n", "e", ":NvimTreeToggle", opts) + +-- Telescope +keymap("n", "ff", ":Telescope find_files", opts) +keymap("n", "ft", ":Telescope live_grep", opts) +keymap("n", "fp", ":Telescope projects", opts) +keymap("n", "fb", ":Telescope buffers", opts) + +-- Git +keymap("n", "gg", "lua _LAZYGIT_TOGGLE()", 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) diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua new file mode 100644 index 0000000..09dbe90 --- /dev/null +++ b/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.format{ async = true }", 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.server_capabilities.documentFormattingProvider = false + end + + if client.name == "sumneko_lua" then + client.server_capabilities.documentFormattingProvider = 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/lua/user/lsp/init.lua b/lua/user/lsp/init.lua new file mode 100644 index 0000000..c8eef0f --- /dev/null +++ b/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.mason" +require("user.lsp.handlers").setup() +require "user.lsp.null-ls" diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua new file mode 100644 index 0000000..af3a665 --- /dev/null +++ b/lua/user/lsp/mason.lua @@ -0,0 +1,52 @@ +local servers = { + "sumneko_lua", + "cssls", + "html", + "tsserver", + "pyright", + "bashls", + "jsonls", + "yamlls", +} + +local settings = { + ui = { + border = "none", + icons = { + package_installed = "◍", + package_pending = "◍", + package_uninstalled = "◍", + }, + }, + log_level = vim.log.levels.INFO, + max_concurrent_installers = 4, +} + +require("mason").setup(settings) +require("mason-lspconfig").setup({ + ensure_installed = servers, + automatic_installation = true, +}) + +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, + } + + server = vim.split(server, "@")[1] + + local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server) + if require_ok then + opts = vim.tbl_deep_extend("force", conf_opts, opts) + end + + lspconfig[server].setup(opts) +end diff --git a/lua/user/lsp/null-ls.lua b/lua/user/lsp/null-ls.lua new file mode 100644 index 0000000..3f24587 --- /dev/null +++ b/lua/user/lsp/null-ls.lua @@ -0,0 +1,24 @@ +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, + formatting.google_java_format, + diagnostics.flake8, + }, +} diff --git a/lua/user/lsp/settings/pyright.lua b/lua/user/lsp/settings/pyright.lua new file mode 100644 index 0000000..c2a518d --- /dev/null +++ b/lua/user/lsp/settings/pyright.lua @@ -0,0 +1,9 @@ +return { + settings = { + python = { + analysis = { + typeCheckingMode = "off", + }, + }, + }, +} diff --git a/lua/user/lsp/settings/sumneko_lua.lua b/lua/user/lsp/settings/sumneko_lua.lua new file mode 100644 index 0000000..1154de2 --- /dev/null +++ b/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/lua/user/lualine.lua b/lua/user/lualine.lua new file mode 100644 index 0000000..463d77b --- /dev/null +++ b/lua/user/lualine.lua @@ -0,0 +1,58 @@ +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 + +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 }, + lualine_x = { diff, spaces, "encoding", filetype }, + lualine_y = { location }, + lualine_z = { "progress" }, + }, +} diff --git a/lua/user/nvim-tree.lua b/lua/user/nvim-tree.lua new file mode 100644 index 0000000..1a41989 --- /dev/null +++ b/lua/user/nvim-tree.lua @@ -0,0 +1,67 @@ +local status_ok, nvim_tree = pcall(require, "nvim-tree") +if not status_ok then + return +end + +local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +if not config_status_ok then + return +end + +local tree_cb = nvim_tree_config.nvim_tree_callback + +nvim_tree.setup { + update_focused_file = { + enable = true, + update_cwd = true, + }, + renderer = { + root_folder_modifier = ":t", + icons = { + glyphs = { + default = "", + symlink = "", + folder = { + arrow_open = "", + arrow_closed = "", + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + symlink_open = "", + }, + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + untracked = "U", + deleted = "", + ignored = "◌", + }, + }, + }, + }, + diagnostics = { + enable = true, + show_on_dirs = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + view = { + width = 30, + side = "left", + mappings = { + list = { + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + }, + }, + }, +} diff --git a/lua/user/options.lua b/lua/user/options.lua new file mode 100644 index 0000000..3c45705 --- /dev/null +++ b/lua/user/options.lua @@ -0,0 +1,40 @@ +vim.opt.backup = false -- creates a backup file +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 = true -- 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.expandtab = true -- convert tabs to spaces +vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation +vim.opt.tabstop = 2 -- insert 2 spaces for a tab +vim.opt.cursorline = true -- highlight the current line +vim.opt.number = true -- set numbered lines +vim.opt.laststatus = 3 -- only the last window will always have a status line +vim.opt.showcmd = false -- hide (partial) command in the last line of the screen (for performance) +vim.opt.ruler = false -- hide the line and column number of the cursor position +vim.opt.numberwidth = 4 -- minimal number of columns to use for the line number {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 -- minimal number of screen lines to keep above and below the cursor +vim.opt.sidescrolloff = 8 -- minimal number of screen columns to keep to the left and right of the cursor if wrap is `false` +vim.opt.guifont = "monospace:h17" -- the font used in graphical neovim applications +vim.opt.fillchars.eob=" " -- show empty lines at the end of a buffer as ` ` {default `~`} +vim.opt.shortmess:append "c" -- hide all the completion messages, e.g. "-- XXX completion (YYY)", "match 1 of 2", "The only match", "Pattern not found" +vim.opt.whichwrap:append("<,>,[,],h,l") -- keys allowed to move to the previous/next line when the beginning/end of line is reached +vim.opt.iskeyword:append("-") -- treats words with `-` as single words diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua new file mode 100644 index 0000000..00389db --- /dev/null +++ b/lua/user/plugins.lua @@ -0,0 +1,109 @@ +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, + }, + git = { + clone_timeout = 300, -- Timeout, in seconds, for git clones + }, +} + +-- Install your plugins here +return packer.startup(function(use) + -- My plugins here + use { "wbthomason/packer.nvim", commit = "6afb67460283f0e990d35d229fd38fdc04063e0a" } -- Have packer manage itself + use { "nvim-lua/plenary.nvim", commit = "4b7e52044bbb84242158d977a50c4cbcd85070c7" } -- Useful lua functions used by lots of plugins + use { "windwp/nvim-autopairs", commit = "4fc96c8f3df89b6d23e5092d31c866c53a346347" } -- Autopairs, integrates with both cmp and treesitter + use { "numToStr/Comment.nvim", commit = "97a188a98b5a3a6f9b1b850799ac078faa17ab67" } + use { "JoosepAlviste/nvim-ts-context-commentstring", commit = "4d3a68c41a53add8804f471fcc49bb398fe8de08" } + use { "kyazdani42/nvim-web-devicons", commit = "563f3635c2d8a7be7933b9e547f7c178ba0d4352" } + use { "kyazdani42/nvim-tree.lua", commit = "7282f7de8aedf861fe0162a559fc2b214383c51c" } + use { "akinsho/bufferline.nvim", commit = "83bf4dc7bff642e145c8b4547aa596803a8b4dc4" } + use { "moll/vim-bbye", commit = "25ef93ac5a87526111f43e5110675032dbcacf56" } + use { "nvim-lualine/lualine.nvim", commit = "a52f078026b27694d2290e34efa61a6e4a690621" } + use { "akinsho/toggleterm.nvim", commit = "2a787c426ef00cb3488c11b14f5dcf892bbd0bda" } + use { "ahmedkhalf/project.nvim", commit = "628de7e433dd503e782831fe150bb750e56e55d6" } + use { "lewis6991/impatient.nvim", commit = "b842e16ecc1a700f62adb9802f8355b99b52a5a6" } + use { "lukas-reineke/indent-blankline.nvim", commit = "db7cbcb40cc00fc5d6074d7569fb37197705e7f6" } + use { "goolord/alpha-nvim", commit = "0bb6fc0646bcd1cdb4639737a1cee8d6e08bcc31" } + + -- Colorschemes + use { "folke/tokyonight.nvim", commit = "66bfc2e8f754869c7b651f3f47a2ee56ae557764" } + use { "lunarvim/darkplus.nvim", commit = "13ef9daad28d3cf6c5e793acfc16ddbf456e1c83" } + + -- cmp plugins + use { "hrsh7th/nvim-cmp", commit = "b0dff0ec4f2748626aae13f011d1a47071fe9abc" } -- The completion plugin + use { "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" } -- buffer completions + use { "hrsh7th/cmp-path", commit = "447c87cdd6e6d6a1d2488b1d43108bfa217f56e1" } -- path completions + use { "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36" } -- snippet completions + use { "hrsh7th/cmp-nvim-lsp", commit = "affe808a5c56b71630f17aa7c38e15c59fd648a8" } + use { "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21" } + + -- snippets + use { "L3MON4D3/LuaSnip", commit = "8f8d493e7836f2697df878ef9c128337cbf2bb84" } --snippet engine + use { "rafamadriz/friendly-snippets", commit = "2be79d8a9b03d4175ba6b3d14b082680de1b31b1" } -- a bunch of snippets to use + + -- LSP + -- use { "williamboman/nvim-lsp-installer", commit = "e9f13d7acaa60aff91c58b923002228668c8c9e6" } -- simple to use language server installer + use { "neovim/nvim-lspconfig", commit = "f11fdff7e8b5b415e5ef1837bdcdd37ea6764dda" } -- enable LSP + use { "williamboman/mason.nvim", commit = "c2002d7a6b5a72ba02388548cfaf420b864fbc12"} + use { "williamboman/mason-lspconfig.nvim", commit = "0051870dd728f4988110a1b2d47f4a4510213e31" } + use { "jose-elias-alvarez/null-ls.nvim", commit = "c0c19f32b614b3921e17886c541c13a72748d450" } -- for formatters and linters + use { "RRethy/vim-illuminate", commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" } + + -- Telescope + use { "nvim-telescope/telescope.nvim", commit = "76ea9a898d3307244dce3573392dcf2cc38f340f" } + + -- Treesitter + use { + "nvim-treesitter/nvim-treesitter", + commit = "8e763332b7bf7b3a426fd8707b7f5aa85823a5ac", + } + + -- Git + use { "lewis6991/gitsigns.nvim", commit = "f98c85e7c3d65a51f45863a34feb4849c82f240f" } + + -- DAP + use { "mfussenegger/nvim-dap", commit = "014ebd53612cfd42ac8c131e6cec7c194572f21d" } + use { "rcarriga/nvim-dap-ui", commit = "d76d6594374fb54abf2d94d6a320f3fd6e9bb2f7" } + use { "ravenxrz/DAPInstall.nvim", commit = "8798b4c36d33723e7bba6ed6e2c202f84bb300de" } + + -- 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/lua/user/project.lua b/lua/user/project.lua new file mode 100644 index 0000000..fb8e591 --- /dev/null +++ b/lua/user/project.lua @@ -0,0 +1,19 @@ +local status_ok, project = pcall(require, "project_nvim") +if not status_ok then + return +end +project.setup({ + + -- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project + detection_methods = { "pattern" }, + + -- patterns used to detect root dir, when **"pattern"** is in detection_methods + patterns = { ".git", "Makefile", "package.json" }, +}) + +local tele_status_ok, telescope = pcall(require, "telescope") +if not tele_status_ok then + return +end + +telescope.load_extension('projects') diff --git a/lua/user/telescope.lua b/lua/user/telescope.lua new file mode 100644 index 0000000..33f8102 --- /dev/null +++ b/lua/user/telescope.lua @@ -0,0 +1,25 @@ +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, + }, + }, + }, +} diff --git a/lua/user/toggleterm.lua b/lua/user/toggleterm.lua new file mode 100644 index 0000000..c6af4d5 --- /dev/null +++ b/lua/user/toggleterm.lua @@ -0,0 +1,40 @@ +local status_ok, toggleterm = pcall(require, "toggleterm") +if not status_ok then + return +end + +toggleterm.setup({ + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + persist_size = true, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + }, +}) + +function _G.set_terminal_keymaps() + local opts = {noremap = true} + -- vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) +end + +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + +local Terminal = require("toggleterm.terminal").Terminal +local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) + +function _LAZYGIT_TOGGLE() + lazygit:toggle() +end + diff --git a/lua/user/treesitter.lua b/lua/user/treesitter.lua new file mode 100644 index 0000000..e9e31df --- /dev/null +++ b/lua/user/treesitter.lua @@ -0,0 +1,31 @@ +local status_ok, treesitter = pcall(require, "nvim-treesitter") +if not status_ok then + return +end + +local status_ok, configs = pcall(require, "nvim-treesitter.configs") +if not status_ok then + return +end + +configs.setup({ + ensure_installed = { "lua", "markdown", "markdown_inline", "bash", "python" }, -- put the language you want in this array + -- ensure_installed = "all", -- one of "all" or a list of languages + ignore_install = { "" }, -- List of parsers to ignore installing + sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) + + 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" } }, + + context_commentstring = { + enable = true, + enable_autocmd = false, + }, + +}) diff --git a/plugin/packer_compiled.lua b/plugin/packer_compiled.lua deleted file mode 100644 index 88e6aad..0000000 --- a/plugin/packer_compiled.lua +++ /dev/null @@ -1,179 +0,0 @@ --- Automatically generated packer.nvim plugin loader code - -if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then - vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') - return -end - -vim.api.nvim_command('packadd packer.nvim') - -local no_errors, error_msg = pcall(function() - -_G._packer = _G._packer or {} -_G._packer.inside_compile = true - -local time -local profile_info -local should_profile = false -if should_profile then - local hrtime = vim.loop.hrtime - profile_info = {} - time = function(chunk, start) - if start then - profile_info[chunk] = hrtime() - else - profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 - end - end -else - time = function(chunk, start) end -end - -local function save_profiles(threshold) - local sorted_times = {} - for chunk_name, time_taken in pairs(profile_info) do - sorted_times[#sorted_times + 1] = {chunk_name, time_taken} - end - table.sort(sorted_times, function(a, b) return a[2] > b[2] end) - local results = {} - for i, elem in ipairs(sorted_times) do - if not threshold or threshold and elem[2] > threshold then - results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' - end - end - if threshold then - table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') - end - - _G._packer.profile_output = results -end - -time([[Luarocks path setup]], true) -local package_path_str = "/home/ateijelo/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/ateijelo/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/ateijelo/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/ateijelo/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" -local install_cpath_pattern = "/home/ateijelo/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" -if not string.find(package.path, package_path_str, 1, true) then - package.path = package.path .. ';' .. package_path_str -end - -if not string.find(package.cpath, install_cpath_pattern, 1, true) then - package.cpath = package.cpath .. ';' .. install_cpath_pattern -end - -time([[Luarocks path setup]], false) -time([[try_loadstring definition]], true) -local function try_loadstring(s, component, name) - local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) - if not success then - vim.schedule(function() - vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) - end) - end - return result -end - -time([[try_loadstring definition]], false) -time([[Defining packer_plugins]], true) -_G.packer_plugins = { - catppuccin = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/catppuccin", - url = "https://github.com/catppuccin/nvim" - }, - ["cmp-nvim-lsp"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", - url = "https://github.com/hrsh7th/cmp-nvim-lsp" - }, - ["cmp-snippy"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/cmp-snippy", - url = "https://github.com/dcampos/cmp-snippy" - }, - ["exrc.nvim"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/exrc.nvim", - url = "https://github.com/MunifTanjim/exrc.nvim" - }, - harpoon = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/harpoon", - url = "https://github.com/ThePrimeagen/harpoon" - }, - ["move.nvim"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/move.nvim", - url = "https://github.com/fedepujol/move.nvim" - }, - ["nvim-cmp"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-cmp", - url = "https://github.com/hrsh7th/nvim-cmp" - }, - ["nvim-comment"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-comment", - url = "https://github.com/terrortylor/nvim-comment" - }, - ["nvim-lspconfig"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", - url = "https://github.com/neovim/nvim-lspconfig" - }, - ["nvim-snippy"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-snippy", - url = "https://github.com/dcampos/nvim-snippy" - }, - ["nvim-treesitter"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-treesitter", - url = "https://github.com/nvim-treesitter/nvim-treesitter" - }, - ["packer.nvim"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/packer.nvim", - url = "https://github.com/wbthomason/packer.nvim" - }, - ["plenary.nvim"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/plenary.nvim", - url = "https://github.com/nvim-lua/plenary.nvim" - }, - ["telescope.nvim"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/telescope.nvim", - url = "https://github.com/nvim-telescope/telescope.nvim" - }, - ["tokyonight.nvim"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/tokyonight.nvim", - url = "https://github.com/folke/tokyonight.nvim" - }, - ["vim-lastplace"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/vim-lastplace", - url = "https://github.com/farmergreg/vim-lastplace" - }, - ["vim-visual-multi"] = { - loaded = true, - path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/vim-visual-multi", - url = "https://github.com/mg979/vim-visual-multi" - } -} - -time([[Defining packer_plugins]], false) - -_G._packer.inside_compile = false -if _G._packer.needs_bufread == true then - vim.cmd("doautocmd BufRead") -end -_G._packer.needs_bufread = false - -if should_profile then save_profiles() end - -end) - -if not no_errors then - error_msg = error_msg:gsub('"', '\\"') - vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') -end