diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1809889 --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +# 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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..417d075 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# nvim-config + +[Salar Rahmanian](https://www.softinio.com) [neovim](https://neovim.io/) + +### Credit + +Based on [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim) by the awesome [TJ DeVries](https://twitter.com/teej_dv) thank you! diff --git a/after/plugin/gitsigns.lua b/after/plugin/gitsigns.lua new file mode 100644 index 0000000..1415cb1 --- /dev/null +++ b/after/plugin/gitsigns.lua @@ -0,0 +1,12 @@ +local installed, gitsigns = pcall(require, 'gitsigns') +if installed then + gitsigns.setup { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + } +end diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua new file mode 100644 index 0000000..242a090 --- /dev/null +++ b/after/plugin/lualine.lua @@ -0,0 +1,13 @@ +local installed, lualine = pcall(require, 'lualine') +if installed then +-- Set lualine as statusline +-- See `:help lualine.txt` + lualine.setup { + options = { + icons_enabled = false, + theme = 'tokyonight', + component_separators = '|', + section_separators = '', + }, + } +end diff --git a/after/plugin/neogit.lua b/after/plugin/neogit.lua new file mode 100644 index 0000000..c114bd0 --- /dev/null +++ b/after/plugin/neogit.lua @@ -0,0 +1,10 @@ +local installed, neogit = pcall(require, 'neogit') +if installed then + neogit.setup { + integrations = { + diffview = true, + }, + } + + vim.api.nvim_set_keymap('n', 'ng', [[lua require('neogit').open({ kind = "split" })]], { noremap = true, silent = true }) +end diff --git a/after/plugin/nvim-tree.lua b/after/plugin/nvim-tree.lua new file mode 100644 index 0000000..3a98976 --- /dev/null +++ b/after/plugin/nvim-tree.lua @@ -0,0 +1,26 @@ +local installed, nvim_tree = pcall(require, 'nvim-tree') +if installed then + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + nvim_tree.setup({ + sort_by = "case_sensitive", + disable_netrw = true, + view = { + adaptive_size = true, + mappings = { + list = { + { key = "u", action = "dir_up" }, + }, + }, + }, + renderer = { + highlight_git = true, + group_empty = true, + }, + filters = { + dotfiles = false, + }, + }) + + vim.api.nvim_set_keymap('n', 'm', [[lua require('nvim-tree').toggle()]], { noremap = true, silent = true }) +end diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua new file mode 100644 index 0000000..6b22add --- /dev/null +++ b/after/plugin/telescope.lua @@ -0,0 +1,37 @@ +local installed, telescope = pcall(require, 'telescope') +if installed then + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, + } + + -- Enable telescope fzf native, if installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'scaladex') + + -- See `:help telescope.builtin` + vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer]' }) + + vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) + +end diff --git a/after/plugin/texlabconfig.lua b/after/plugin/texlabconfig.lua new file mode 100644 index 0000000..0dd1e37 --- /dev/null +++ b/after/plugin/texlabconfig.lua @@ -0,0 +1,36 @@ +local installed, texlabconfig = pcall(require, 'texlabconfig') +if installed then + -- vimtex + vim.g.vimtex_view_method = 'skim' + vim.g.vimtex_compiler_method = 'tectonic' + + -- nvim-texlabconfig + local tex_preview_executable = '/Applications/Skim.app/Contents/SharedSupport/displayline' + local tex_preview_args = {"%l", "%p", "%f"} + local texlab_build_executable = 'tectonic' + local texlab_build_args = { + '-X', + 'compile', + '%f', + '--synctex', + '--keep-logs', + '--keep-intermediates' + } + texlabconfig.setup { + cache_activate = true, + cache_filetypes = { 'tex', 'bib' }, + reverse_search_edit_cmd = vim.cmd.edit, + settings = { + texlab = { + build = { + executable = texlab_build_executable, + args = texlab_build_args + }, + forwardSearch = { + executable = tex_preview_executable, + args = tex_preview_args + } + } + } + } +end diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 0000000..c60473f --- /dev/null +++ b/after/plugin/treesitter.lua @@ -0,0 +1,117 @@ +local installed, treesitter = pcall(require, 'nvim-treesitter.configs') +if installed then + -- [[ Configure Treesitter ]] + -- See `:help nvim-treesitter` + treesitter.setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { + 'c', + 'cpp', + 'go', + 'lua', + 'python', + 'rust', + 'typescript', + 'help', + 'vim', + 'scala', + 'bash', + 'dockerfile', + 'fish', + 'git_rebase', + 'gitattributes', + 'gitcommit', + 'gitignore', + 'haskell', + 'hocon', + 'html', + 'http', + 'java', + 'javascript', + 'json', + 'json5', + 'latex', + 'make', + 'markdown_inline', + 'nix', + 'sql', + 'terraform', + 'yaml' + }, + + highlight = { enable = true }, + indent = { enable = true, disable = { 'python' } }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + playground = { + enable = true, + disable = {}, + updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code + persist_queries = false, -- Whether the query persists across vim sessions + keybindings = { + toggle_query_editor = 'o', + toggle_hl_groups = 'i', + toggle_injected_languages = 't', + toggle_anonymous_nodes = 'a', + toggle_language_display = 'I', + focus_language = 'f', + unfocus_language = 'F', + update = 'R', + goto_node = '', + show_help = '?', + }, + }, + }, + }, + } +end + diff --git a/init.lua b/init.lua index 4ca3cba..7384b7d 100644 --- a/init.lua +++ b/init.lua @@ -166,17 +166,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { pattern = '*', }) --- Set lualine as statusline --- See `:help lualine.txt` -require('lualine').setup { - options = { - icons_enabled = false, - theme = 'onedark', - component_separators = '|', - section_separators = '', - }, -} - -- Enable Comment.nvim require('Comment').setup() @@ -187,203 +176,11 @@ require('indent_blankline').setup { show_trailing_blankline_indent = false, } --- Gitsigns --- See `:help gitsigns.txt` -require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, -} - --- neogit -require('neogit').setup { - integrations = { - diffview = true, - }, -} - --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, -} - require('trouble').setup() -- nvim-autopairs require('nvim-autopairs').setup() - -- vimtex - vim.g.vimtex_view_method = 'skim' - vim.g.vimtex_compiler_method = 'tectonic' - - -- nvim-texlabconfig - local tex_preview_executable = '/Applications/Skim.app/Contents/SharedSupport/displayline' - local tex_preview_args = {"%l", "%p", "%f"} - local texlab_build_executable = 'tectonic' - local texlab_build_args = { - '-X', - 'compile', - '%f', - '--synctex', - '--keep-logs', - '--keep-intermediates' - } - require('texlabconfig').setup { - cache_activate = true, - cache_filetypes = { 'tex', 'bib' }, - reverse_search_edit_cmd = vim.cmd.edit, - settings = { - texlab = { - build = { - executable = texlab_build_executable, - args = texlab_build_args - }, - forwardSearch = { - executable = tex_preview_executable, - args = tex_preview_args - } - } - } - } - - -- nvim-tree - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - require("nvim-tree").setup({ - sort_by = "case_sensitive", - disable_netrw = true, - view = { - adaptive_size = true, - mappings = { - list = { - { key = "u", action = "dir_up" }, - }, - }, - }, - renderer = { - highlight_git = true, - group_empty = true, - }, - filters = { - dotfiles = false, - }, - }) - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') -pcall(require('telescope').load_extension, 'scaladex') - --- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer]' }) - -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) - --- [[ Configure Treesitter ]] --- See `:help nvim-treesitter` -require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - -- ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'typescript', 'help', 'vim' }, - ensure_installed = "all", - - highlight = { enable = true }, - indent = { enable = true, disable = { 'python' } }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - playground = { - enable = true, - disable = {}, - updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code - persist_queries = false, -- Whether the query persists across vim sessions - keybindings = { - toggle_query_editor = 'o', - toggle_hl_groups = 'i', - toggle_injected_languages = 't', - toggle_anonymous_nodes = 'a', - toggle_language_display = 'I', - focus_language = 'f', - unfocus_language = 'F', - update = 'R', - goto_node = '', - show_help = '?', - }, - }, - }, - }, -} - -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) @@ -538,9 +335,5 @@ cmp.event:on( cmp_autopairs.on_confirm_done() ) -vim.api.nvim_set_keymap('n', 'm', [[lua require('nvim-tree').toggle()]], { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'ng', [[lua require('neogit').open({ kind = "split" })]], { noremap = true, silent = true }) - - -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et