diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index c77063d..474b6dc 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,69 +1,11 @@ --- disable netrw at the very start of your init.lua (strongly advised) -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 ----------------------- --- general settings -- ----------------------- -local set = vim.opt +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" -set.foldmethod = 'marker' +require("config.options") +require("config.lazy") -set.wrap = true -set.linebreak = true -set.breakindent = true -set.breakindentopt = {'shift:2', 'sbr'} -set.showbreak = ' >' - -set.number = true -set.relativenumber = true -set.encoding = "utf-8" - --- search -set.hlsearch = true -set.ignorecase = true -set.smartcase = true - --- indentation -set.smarttab = true -set.expandtab = false -set.copyindent = true -set.preserveindent = true -set.tabstop = 4 -set.shiftwidth = 4 -set.softtabstop = 0 - -local mdgroup = vim.api.nvim_create_augroup("WrapMarkdown", { clear = true }) -vim.api.nvim_create_autocmd("FileType", { - pattern = "markdown,txt", - callback = function() - vim.opt_local.colorcolumn = "85" - vim.opt_local.textwidth = 85 - end, - group = WrapMarkdown, -}) -vim.api.nvim_create_autocmd("FileType", { - pattern = "latex,tex", - callback = function() - vim.opt_local.shiftwidth = 2 - vim.opt_local.tabstop = 2 - end, -}) -vim.api.nvim_create_autocmd("TextYankPost", { - command = "silent! lua vim.highlight.on_yank()", -}) - -vim.cmd [[ - let g:vim_markdown_folding_disabled=1 -]] - --- removes the background color to have it transparent -vim.api.nvim_create_autocmd({"ColorScheme"}, { - pattern = {"*"}, - command = "hi Normal ctermbg=none guibg=none", -}) -vim.cmd("colorscheme kanagawa") - -require('plugins') ---require('core.colors') -require('core.mappings') +-- mappings +vim.keymap.set("n", "", "/<++>ca>") +vim.keymap.set("n", "s", "") +vim.cmd[[colorscheme tokyonight]] diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..9e62113 --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,37 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { "folke/which-key.nvim", lazy = true }, + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true + -- use opts = {} for passing setup options + -- this is equivalent to setup({}) function + }, + { "christoomey/vim-tmux-navigator" }, + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "tokyonight" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua new file mode 100644 index 0000000..fe40686 --- /dev/null +++ b/.config/nvim/lua/config/options.lua @@ -0,0 +1,32 @@ +vim.opt.wrap = true +vim.opt.linebreak = true +vim.opt.breakindent = true +vim.opt.breakindentopt = {'shift:2', 'sbr'} +vim.opt.showbreak = ' >' + +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.encoding = "utf-8" + +-- search +vim.opt.hlsearch = true +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- indentation +vim.opt.smarttab = true +vim.opt.expandtab = false +vim.opt.copyindent = true +vim.opt.preserveindent = true +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.softtabstop = 0 + +vim.api.nvim_create_autocmd('FileType', { + pattern = { "*.py" }, + callback = function() + vim.opt.expandtab = true + vim.opt.tabstop = 4 + vim.opt.shiftwidth = 4 + end +}) diff --git a/.config/nvim/lua/core/mappings.lua b/.config/nvim/lua/core/mappings.lua deleted file mode 100644 index 7af80e8..0000000 --- a/.config/nvim/lua/core/mappings.lua +++ /dev/null @@ -1,14 +0,0 @@ --------------- --- mappings -- --------------- -local map = vim.api.nvim_set_keymap - -vim.g.mapleader = ' ' -map('n', '', '', {}) -map('n', 'n', ':bnext', {}) -map('n', 'p', ':bprevious', {}) -map('n', 'h', ':nohlsearch', {}) - --- nvim-tree mappings -map('n', 't', ':NvimTreeToggle', {}) -map('n', 'z', ':ZenMode', {}) diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..da7de24 --- /dev/null +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,15 @@ +return { + -- the colorscheme should be available when starting Neovim + { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + opts = { + transparent = true, + styles = { + sidebars = "transparent", + floats = "transparent", + }, + } + } +} diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua deleted file mode 100644 index b326656..0000000 --- a/.config/nvim/lua/plugins/init.lua +++ /dev/null @@ -1,95 +0,0 @@ -------------- --- plugins -- -------------- -require "paq" { - "savq/paq-nvim"; -- Let Paq manage itself - -- general plugins - "nvim-lualine/lualine.nvim"; - --{ 'nvim-tree/nvim-web-devicons', opt=true }; - 'nvim-tree/nvim-web-devicons'; - 'romgrk/barbar.nvim'; - 'ggandor/lightspeed.nvim'; - 'L3MON4D3/LuaSnip'; -- Snippets plugin - 'saadparwaiz1/cmp_luasnip'; -- Snippets source for nvim-cmp - - -- colorschemes -- - 'rebelot/kanagawa.nvim'; - 'folke/tokyonight.nvim'; - - -- code related -- - 'neovim/nvim-lspconfig'; -- Configs for Nvim LSP - 'hrsh7th/nvim-cmp'; -- Autocompletion plugin - 'hrsh7th/cmp-nvim-lsp'; -- LSP source for nvim-cmp - - 'nvim-lua/plenary.nvim'; -- Dependency for telescope - 'nvim-telescope/telescope.nvim'; -- Fuzzy finder - {'nvim-telescope/telescope-fzf-native.nvim', run='make' }; - 'nvim-treesitter/nvim-treesitter'; -- Better syntax highlighting - 'nvim-tree/nvim-tree.lua'; -- File Explorer - 'numToStr/Comment.nvim'; -- Quickly comment lines - 'windwp/nvim-autopairs'; - 'tpope/vim-surround'; - 'lukas-reineke/indent-blankline.nvim'; - 'ap/vim-css-color'; - - -- writing - 'dhruvasagar/vim-table-mode'; - 'folke/zen-mode.nvim'; - 'folke/twilight.nvim'; -} - --- looks like tablemode for vim-table-mode in markdown -vim.cmd [[ -function! s:isAtStartOfLine(mapping) - let text_before_cursor = getline('.')[0 : col('.')-1] - let mapping_pattern = '\V' . escape(a:mapping, '\') - let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\') - return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$') -endfunction - -inoreabbrev - \ isAtStartOfLine('\|\|') ? - \ ':TableModeEnable' : '' -inoreabbrev __ - \ isAtStartOfLine('__') ? - \ ':silent! TableModeDisable' : '__' -]] - -require'plugins.lualine' -require'plugins.nvim-treesitter' -require'plugins.nvim-cmp' -require'plugins.telescope' - -require'Comment'.setup() -require'nvim-tree'.setup() -require'indent_blankline'.setup{ - show_current_context = true, -} -require'nvim-web-devicons'.setup{ - color_icons = true; - default = true; -} --- setup barbar -require'bufferline'.setup{ - icons = true, -} - -require'zen-mode'.setup{ - window = { - width = 85, - }, - plugins = { - options = { - enabled = true, - }, - kitty = { - enabled = true, - font = "+4", - }, - }, -} -require'twilight'.setup{ - dimming = { - alpha = 0.80, - }, -} diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua deleted file mode 100644 index 9c697f1..0000000 --- a/.config/nvim/lua/plugins/lualine.lua +++ /dev/null @@ -1,28 +0,0 @@ -require'lualine'.setup { - options = { - icons_enabled = true, - theme = 'auto', - component_separators = { left = '', right = ''}, - section_separators = { left = '', right = ''}, - disabled_filetypes = {}, - always_divide_middle = true, - }, - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', 'diagnostics'}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'location'}, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = {} -} diff --git a/.config/nvim/lua/plugins/mini.lua b/.config/nvim/lua/plugins/mini.lua new file mode 100644 index 0000000..551b15a --- /dev/null +++ b/.config/nvim/lua/plugins/mini.lua @@ -0,0 +1,21 @@ +return{ + {'echasnovski/mini.nvim', version = '*'}, + { + 'echasnovski/mini.surround', + version = '*', + opts = { + mappings = { + add = 'sa', -- Add surrounding in Normal and Visual modes + delete = 'sd', -- Delete surrounding + find = 'sf', -- Find surrounding (to the right) + find_left = 'sF', -- Find surrounding (to the left) + highlight = 'sh', -- Highlight surrounding + replace = 'sr', -- Replace surrounding + update_n_lines = 'sn', -- Update `n_lines` + + suffix_last = 'l', -- Suffix to search with "prev" method + suffix_next = 'n', -- Suffix to search with "next" method + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua deleted file mode 100644 index e904b09..0000000 --- a/.config/nvim/lua/plugins/nvim-cmp.lua +++ /dev/null @@ -1,74 +0,0 @@ -local luasnip = require 'luasnip' -local cmp = require 'cmp' -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm { - 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, - }, - sources = { - { name = 'path'}, - { name = 'nvim_lsp', keywordlength=3 }, - { name = 'buffer', keywordlength=3 }, - { name = 'luasnip', keywordlength=2 }, - }, -} - -require('nvim-autopairs').setup{} -cmp.event:on( - 'confirm_done', - require('nvim-autopairs.completion.cmp').on_confirm_done({ - map_char = { tex = '' } - }) -) - --------------------- --- Configure LSPs -- --------------------- --- require'lspconfig'.pylsp.setup{} - --- Add additional capabilities supported by nvim-cmp -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - -local lspconfig = require('lspconfig') - --- Enable some language servers with the additional completion capabilities offered by nvim-cmp -local servers = { 'clangd', 'rust_analyzer', 'pylsp', 'tsserver', 'jdtls' } -for _, lsp in ipairs(servers) do - lspconfig[lsp].setup { - capabilities = capabilities, - } -end - -vim.opt.completeopt = {'menu', 'menuone', 'noselect'} diff --git a/.config/nvim/lua/plugins/nvim-treesitter.lua b/.config/nvim/lua/plugins/nvim-treesitter.lua deleted file mode 100644 index adf3161..0000000 --- a/.config/nvim/lua/plugins/nvim-treesitter.lua +++ /dev/null @@ -1,15 +0,0 @@ -require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" - ensure_installed = { "lua", "python", "java" }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - highlight = { - -- `false` will disable the whole extension - enable = true, - - -- Using this option may slow down your editor, and you may see some duplicate highlights. - additional_vim_regex_highlighting = false, - }, -} diff --git a/.config/nvim/lua/plugins/tabout.lua b/.config/nvim/lua/plugins/tabout.lua new file mode 100644 index 0000000..ae34333 --- /dev/null +++ b/.config/nvim/lua/plugins/tabout.lua @@ -0,0 +1,43 @@ +return { + { + 'abecodes/tabout.nvim', + lazy = false, + config = function() + require('tabout').setup { + tabkey = '', -- key to trigger tabout, set to an empty string to disable + backwards_tabkey = '', -- key to trigger backwards tabout, set to an empty string to disable + act_as_tab = true, -- shift content if tab out is not possible + act_as_shift_tab = false, -- reverse shift content if tab out is not possible (if your keyboard/terminal supports ) + default_tab = '', -- shift default action (only at the beginning of a line, otherwise is used) + default_shift_tab = '', -- reverse shift default action, + enable_backwards = true, -- well ... + completion = false, -- if the tabkey is used in a completion pum + tabouts = { + { open = "'", close = "'" }, + { open = '"', close = '"' }, + { open = '`', close = '`' }, + { open = '(', close = ')' }, + { open = '[', close = ']' }, + { open = '{', close = '}' } + }, + ignore_beginning = true, --[[ if the cursor is at the beginning of a filled element it will rather tab out than shift the content ]] + exclude = {} -- tabout will ignore these filetypes + } + end, + dependencies = { -- These are optional + "nvim-treesitter/nvim-treesitter", + -- "L3MON4D3/LuaSnip", + -- "hrsh7th/nvim-cmp" + }, + opt = true, -- Set this to true if the plugin is optional + event = 'InsertCharPre', -- Set the event to 'InsertCharPre' for better compatibility + priority = 1000, + }, + -- { + -- "L3MON4D3/LuaSnip", + -- keys = function() + -- -- Disable default tab keybinding in LuaSnip + -- return {} + -- end, + -- }, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 02d8e7b..dd0d696 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,22 +1,16 @@ -require('telescope').setup{ - defaults = { - -- Default configuration for telescope goes here: - -- config_key = value, - mappings = { - i = { - -- map actions.which_key to (default: ) - -- actions.which_key shows the mappings for your picker, - -- e.g. git_{create, delete, ...}_branch for the git_branches picker - [""] = "which_key" - } - } - }, +return { -- fuzzy find + { + "nvim-telescope/telescope.nvim", + dependencies = { + {"nvim-lua/plenary.nvim"}, + {"nvim-tree/nvim-web-devicons"} + }, + config = function() + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) + vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) + vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) + vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) + end, + }, } -require('telescope').load_extension('fzf') - --- mappings -- -local builtin = require('telescope.builtin') -vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'fg', builtin.live_grep, {}) -vim.keymap.set('n', 'fb', builtin.buffers, {}) -vim.keymap.set('n', 'fh', builtin.help_tags, {}) diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..feaabc7 --- /dev/null +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,46 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = { "BufReadPre", "BufNewFile" }, + lazy = vim.fn.argc(-1) == 0, + cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, + keys = { + { "", desc = "Increment Selection" }, + { "", desc = "Decrement Selection", mode = "x" }, + }, + opts_extend = { "ensure_installed" }, + ---@type TSConfig + ---@diagnostic disable-next-line: missing-fields + opts = { + highlight = { enable = true }, + indent = { enable = true }, + ensure_installed = { + "bash", + "c", + "diff", + "html", + "lua", + "markdown", + "markdown_inline", + "python", + "query", + "vim", + "vimdoc", + "yaml" + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end, + } +}