diff --git a/.gitignore b/.gitignore index ac91f76..ff24380 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ vim/.netrwhist vim/spell + +nvim/plugin diff --git a/gitconfig b/gitconfig index 04b8171..e95abab 100644 --- a/gitconfig +++ b/gitconfig @@ -5,7 +5,7 @@ branch = auto ui = auto [core] - editor = vim + editor = nvim attributesfile = ~/.gitattributes excludesfile = ~/.gitignore filemode = false @@ -24,8 +24,6 @@ command = ~/bin/git-imgdiff [push] default = simple -[credential] - helper = libsecret [pager] diff = diff-highlight | less show = diff-highlight | less diff --git a/install-nerdfonts.sh b/install-nerdfonts.sh new file mode 100755 index 0000000..b1d354f --- /dev/null +++ b/install-nerdfonts.sh @@ -0,0 +1,11 @@ +mkdir -p ~/.fonts +cd ~/.fonts +wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.0/RobotoMono.zip +wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.0/Inconsolata.zip +wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.0/FiraCode.zip + +unzip -o RobotoMono.zip +unzip -o Inconsolata.zip +unzip -o FiraCode.zip + +sudo fc-cache -vf ~/.fonts diff --git a/install.sh b/install.sh index 1f94847..a9236f3 100755 --- a/install.sh +++ b/install.sh @@ -22,6 +22,7 @@ $(create-alias zshrc ~/.zshrc) $(create-alias tmux.conf ~/.tmux.conf) $(create-alias gitconfig ~/.gitconfig) $(create-alias gitignore ~/.gitignore) +$(create-alias nvim ~/.config/nvim) $(create-alias vscode-settings.json ~/.config/Code/User/settings.json) $(create-alias vscode-keybindings.json ~/.config/Code/User/keybindings.json) $(create-alias vscode-snippets ~/.config/Code/User/snippets) diff --git a/nvim/after/plugin/colorscheme.lua b/nvim/after/plugin/colorscheme.lua new file mode 100644 index 0000000..869cc44 --- /dev/null +++ b/nvim/after/plugin/colorscheme.lua @@ -0,0 +1 @@ +vim.cmd([[colorscheme gruvbox]]) diff --git a/nvim/after/plugin/lsp.lua b/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..b72116b --- /dev/null +++ b/nvim/after/plugin/lsp.lua @@ -0,0 +1,43 @@ +local lsp = require('lsp-zero').preset({ +}) + +lsp.on_attach(function(client, bufnr) + lsp.default_keymaps({buffer = bufnr}) +end) + +lsp.setup_servers({ + 'tsserver', + 'eslint', +}) + +-- Configure lua language server for neovim +require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls()) + + +lsp.setup() + +local cmp = require('cmp') +local cmp_action = require('lsp-zero').cmp_action() +local cmp_select_opts = {behavior = cmp.SelectBehavior.Select} + + +cmp.setup({ + mapping = { + -- `Enter` key to confirm completion + [''] = cmp.mapping.confirm({select = false}), + + -- Navigate between completions + [''] = cmp.mapping.select_prev_item(cmp_select_opts), + [''] = cmp.mapping.select_next_item(cmp_select_opts), + + [''] = cmp_action.tab_complete(), + [''] = cmp_action.select_prev_or_fallback(), + + -- Ctrl+Space to trigger completion menu + [''] = cmp.mapping.complete(), + + -- Navigate between snippet placeholder + [''] = cmp_action.luasnip_jump_forward(), + [''] = cmp_action.luasnip_jump_backward(), + } +}) diff --git a/nvim/after/plugin/lualine.lua b/nvim/after/plugin/lualine.lua new file mode 100644 index 0000000..92d9172 --- /dev/null +++ b/nvim/after/plugin/lualine.lua @@ -0,0 +1,14 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'dracula', + }, + sections = { + lualine_a = { + { + 'filename', + path = 1, + } + } + } +} diff --git a/nvim/after/plugin/null-ls.lua b/nvim/after/plugin/null-ls.lua new file mode 100644 index 0000000..1bd6270 --- /dev/null +++ b/nvim/after/plugin/null-ls.lua @@ -0,0 +1,16 @@ +local null_ls = require("null-ls") + +local formatting = null_ls.builtins.formatting +local diagnostics = null_ls.builtins.diagnostics +local completion = null_ls.builtins.completion + +null_ls.setup({ + sources = { + formatting.stylua, + formatting.prettier, + diagnostics.eslint, + completion.spell, + }, +}) + +vim.keymap.set('n', 'k', function() vim.lsp.buf.format() end) diff --git a/nvim/after/plugin/nvim-comment.lua b/nvim/after/plugin/nvim-comment.lua new file mode 100644 index 0000000..e1f1358 --- /dev/null +++ b/nvim/after/plugin/nvim-comment.lua @@ -0,0 +1 @@ +require('nvim_comment').setup() diff --git a/nvim/after/plugin/nvim-tree.lua b/nvim/after/plugin/nvim-tree.lua new file mode 100644 index 0000000..9fddd4f --- /dev/null +++ b/nvim/after/plugin/nvim-tree.lua @@ -0,0 +1,11 @@ +# Disable netrw (standard vim file manager) +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +require("nvim-tree").setup({ + view = { + adaptive_size = true + } +}) + +vim.keymap.set('n', '', ':NvimTreeFindFileToggle') diff --git a/nvim/after/plugin/telescope.lua b/nvim/after/plugin/telescope.lua new file mode 100644 index 0000000..db35c0c --- /dev/null +++ b/nvim/after/plugin/telescope.lua @@ -0,0 +1,6 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'p', builtin.find_files, {}) +vim.keymap.set('n', '', builtin.git_files, {}) +vim.keymap.set('n', 'f', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }); +end) diff --git a/nvim/after/plugin/treesitter.lua b/nvim/after/plugin/treesitter.lua new file mode 100644 index 0000000..b239877 --- /dev/null +++ b/nvim/after/plugin/treesitter.lua @@ -0,0 +1,21 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "javascript", "typescript" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + highlight = { + enable = true, + + -- 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, + }, +} diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..a2af934 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,3 @@ +require("core.keymaps") +require("core.plugins") +require("core.set") diff --git a/nvim/lua/core/keymaps.lua b/nvim/lua/core/keymaps.lua new file mode 100644 index 0000000..645891a --- /dev/null +++ b/nvim/lua/core/keymaps.lua @@ -0,0 +1,2 @@ +vim.g.mapleader = 'ö' +vim.g.maplocalleader = 'ö' diff --git a/nvim/lua/core/plugins.lua b/nvim/lua/core/plugins.lua new file mode 100644 index 0000000..f59b6a1 --- /dev/null +++ b/nvim/lua/core/plugins.lua @@ -0,0 +1,61 @@ +local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) + vim.cmd [[packadd packer.nvim]] + return true + end + return false +end + +local packer_bootstrap = ensure_packer() + +return require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + use 'ellisonleao/gruvbox.nvim' + use 'nvim-tree/nvim-tree.lua' + use 'nvim-tree/nvim-web-devicons' + use 'nvim-lualine/lualine.nvim' + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.1', + requires = { {'nvim-lua/plenary.nvim'} } + } + use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) + use('terrortylor/nvim-comment') + use({ + "kylechui/nvim-surround", + tag = "*", -- Use for stability; omit to use `main` branch for the latest features + config = function() + require("nvim-surround").setup({}) + end, + requires = { "nvim-lua/plenary.nvim" }, + }) + use { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + requires = { + -- LSP Support + {'neovim/nvim-lspconfig'}, -- Required + { -- Optional + 'williamboman/mason.nvim', + run = function() + pcall(vim.cmd, 'MasonUpdate') + end, + }, + {'williamboman/mason-lspconfig.nvim'}, -- Optional + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, -- Required + {'hrsh7th/cmp-nvim-lsp'}, -- Required + {'L3MON4D3/LuaSnip'}, -- Required + } + } + use 'jose-elias-alvarez/null-ls.nvim' + + -- 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/nvim/lua/core/set.lua b/nvim/lua/core/set.lua new file mode 100644 index 0000000..542ad66 --- /dev/null +++ b/nvim/lua/core/set.lua @@ -0,0 +1,25 @@ +vim.opt.number = true -- show line numbers + +vim.opt.tabstop = 2 -- a tab is two spaces +vim.opt.softtabstop = 2 -- a tab is two spaces in insert +vim.opt.shiftwidth = 2 -- an autoindent (with <<) is two spaces +vim.opt.expandtab = true -- use spaces, not tabs +vim.opt.smartindent = true -- use smart autoindent + +vim.opt.wrap = false -- don't wrap lines + +vim.opt.swapfile = false -- don't use a swapfile +vim.opt.backup = false -- don't use a backup +vim.opt.undofile = true -- use an undo file instead + +vim.opt.ignorecase = true -- ignore casing in searches +vim.opt.smartcase = true -- enable casing in searches if there is an upper case letter in the search + +vim.opt.list = true -- show invisible characters (tabs and trailing spaces) + +vim.opt.termguicolors = true -- enables 24-bit RGB colors + +vim.opt.scrolloff = 4 -- always show 4 lines above and below +vim.opt.sidescrolloff = 4 -- always show 4 columns left and right + +vim.opt.autowrite = true -- write when buffers are changed diff --git a/nvim/stylua.toml b/nvim/stylua.toml new file mode 100644 index 0000000..394e884 --- /dev/null +++ b/nvim/stylua.toml @@ -0,0 +1 @@ +indent_type = "Spaces" diff --git a/zshrc b/zshrc index b9c052b..f95f40d 100644 --- a/zshrc +++ b/zshrc @@ -52,7 +52,7 @@ alias grb="git rebase" alias gdc="git diff --cached" alias gst="git stash" alias git-remote-cleanup="git remote prune origin" -alias gbam="git branch --merged master | grep -v master | xargs git branch -d" +alias gbam="echo 'Use gbda from oh my zsh git plugin instead'" alias gpn="git push --no-verify" alias sagi="sudo apt-get install"