Skip to content

Commit

Permalink
feat: configure nvim
Browse files Browse the repository at this point in the history
  • Loading branch information
tagoro9 committed Apr 26, 2021
1 parent 0f6285d commit 587b7c8
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ brew "hub"
brew "jenv"
brew "k9s"
brew "kubectx"
brew "luajit", args: ['HEAD']
brew "neovim", args: ['HEAD']
brew "pinentry-mac"
brew "pyenv"
brew "reattach-to-user-namespace"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ My dotfiles.
## Installation

1. Clone this repository.
2. Run `./script/setup`.
3. Install and configure [meslo-nerd-font-patched-for-powerlevel10k](https://github.com/romkatv/powerlevel10k#meslo-nerd-font-patched-for-powerlevel10k) font.
1. Run `./script/setup`.
1. Install and configure [meslo-nerd-font-patched-for-powerlevel10k](https://github.com/romkatv/powerlevel10k#meslo-nerd-font-patched-for-powerlevel10k) font.

## Folder structure

Expand Down
10 changes: 10 additions & 0 deletions config/nvim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require('plugins')

require('general.sets')
require('general.netrw')
require('general.mappings')
require('general.colors')

require('plugins/airline')
require('plugins/treesitter')
require('plugins/lsp')
2 changes: 2 additions & 0 deletions config/nvim/lua/general/colors.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vim.cmd('colorscheme dracula')
vim.g.dracula_colorterm = false
41 changes: 41 additions & 0 deletions config/nvim/lua/general/mappings.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
local map = vim.api.nvim_set_keymap
local globals = vim.g

-- map the leader key
map('n', '<Space>', '', {})
globals.mapleader = ' '

options = { noremap = true }
map('n', '<M-j>', ':nohlsearch<cr>', options)

-- alt + hjkl to resize windows in normal mode
map('n', '<M-h>', ':vertical resize -2<CR>', options)
map('n', '<M-j>', ':resize -2<CR>', options)
map('n', '<M-k>', ':resize +2<CR>', options)
map('n', '<M-l>', ':vertical resize +2<CR>', options)

-- ctrl + hjkl to move between windows in normal mode
map('n', '<C-h>', '<C-w>h', options)
map('n', '<C-j>', '<C-w>j', options)
map('n', '<C-k>', '<C-w>k', options)
map('n', '<C-l>', '<C-w>l', options)

-- Telescope command-line sugar
map('n', '<leader>ff', '<cmd>Telescope find_files<CR>', options)
map('n', '<leader>fg', '<cmd>Telescope live_grep<CR>', options)
map('n', '<leader>fb', '<cmd>Telescope buffers<CR>', options)
map('n', '<leader>fh', '<cmd>Telescope help_tags<CR>', options)

-- Open netrw
map('n', '<leader>pv', ':Vexplore<CR>', options)


-- [jk | kl] instead of ESC in insert mode
map('i', 'jk' , '<ESC>', options)
map('i', 'kj' , '<ESC>', options)

-- Don't use arrow keys in insert mode
map('i', '<up>', '<nop>', options)
map('i', '<down>', '<nop>', options)
map('i', '<left>', '<nop>', options)
map('i', '<right>', '<nop>', options)
6 changes: 6 additions & 0 deletions config/nvim/lua/general/netrw.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vim.g.netrw_browse_split = 0
vim.g.netrw_fastbrowse = 0
vim.g.netrw_banner = 0
vim.g.netrw_winsize = 25
vim.g.netrw_liststyle = 3

28 changes: 28 additions & 0 deletions config/nvim/lua/general/sets.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local o = vim.o
local wo = vim.wo
local bo = vim.bo

-- global options
o.splitbelow = true
o.splitright = true
o.guicursor = ''
o.termguicolors = true -- icons are not displayed with the correct colors
o.showmode = false
o.incsearch = true
o.hlsearch = false
o.hidden = true
o.scrolloff=8
o.completeopt="menuone,noinsert,noselect"
-- Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable delays and poor user experience.
o.updatetime = 50

-- buffer-local options
bo.expandtab = true
bo.smartindent = true
bo.tabstop = 4
bo.softtabstop = 4
bo.shiftwidth = 4

-- window-local options
wo.wrap = false
wo.relativenumber = true
2 changes: 2 additions & 0 deletions config/nvim/lua/plugins/airline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vim.g.airline_theme='dracula'
vim.g.airline_powerline_fonts = true
18 changes: 18 additions & 0 deletions config/nvim/lua/plugins/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local cmd = vim.cmd
cmd 'packadd paq-nvim'
local paq = require('paq-nvim').paq

paq{'savq/paq-nvim', opt=true}
paq { 'dracula/vim', as = 'dracula' }
paq { 'nvim-lua/plenary.nvim' }
paq { 'nvim-lua/popup.nvim' }
paq { 'nvim-telescope/telescope.nvim' }
paq { 'nvim-treesitter/nvim-treesitter' }
paq { 'vim-airline/vim-airline' }
paq { 'vim-airline/vim-airline-themes' }
paq { 'tpope/vim-fugitive' }
paq { 'kyazdani42/nvim-web-devicons' }
paq { 'neovim/nvim-lspconfig' }
paq { 'kabouzeid/nvim-lspinstall' }
paq { 'nvim-lua/completion-nvim' }

29 changes: 29 additions & 0 deletions config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local on_attach = require'completion'.on_attach

-- config that activates keymaps and enables snippet support
local function make_config()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
return {
capabilities = capabilities,
on_attach = on_attach,
}
end

-- lsp-install
local function setup_servers()
require'lspinstall'.setup()
local servers = require'lspinstall'.installed_servers()
local config = make_config()
for _, server in pairs(servers) do
require'lspconfig'[server].setup(config)
end
end

setup_servers()

-- Automatically reload after `:LspInstall <server>` so we don't have to restart neovim
require'lspinstall'.post_install_hook = function ()
setup_servers() -- reload installed servers
vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
end
13 changes: 13 additions & 0 deletions config/nvim/lua/plugins/treesitter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require('nvim-treesitter.configs').setup {
ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
ignore_install = { "haskell" }, -- List of parsers to ignore installing
highlight = {
enable = true, -- false will disable the whole extension
},
incremental_selection = {
enable = true, -- false will disable the whole extension
},
ident = {
enable = true, -- false will disable the whole extension
},
}
4 changes: 4 additions & 0 deletions config/shells/common/aliases.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Alias Hub to get a better Github integration
eval "$(hub alias -s)"

# Alias vim to our default editor
alias vim='${EDITOR:-vim}'
alias vi='${EDITOR:-vim}'

# Some better aliases
alias cp='cp -iv'
alias mv='mv -iv'
Expand Down
7 changes: 6 additions & 1 deletion config/shells/common/settings.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Default editor
export EDITOR=vim
if type nvim > /dev/null 2>&1;
then
export EDITOR=nvim
else
export EDITOR=vim
fi

# Ant configuration
export ANT_OPTS='-Xms768m -Xmx1024m'
Expand Down
1 change: 1 addition & 0 deletions install.conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
glob: true
path: config/bin/*
relink: true
~/.config/nvim: config/nvim
~/.config/shells: config/shells
~/.gitconfig: config/git/gitconfig
~/.gitignore_global: config/git/gitignore_global
Expand Down
11 changes: 10 additions & 1 deletion script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
}

# Set zsh as default terminal
if [ "$SHELL" != "/usr/local/bin/zsh"]; then
if [ "$SHELL" != "/usr/local/bin/zsh" ]; then
echo -e "🛠 Setting zsh as default shell…"
eval $(chsh -s /usr/local/bin/zsh)
fi
fi
Expand Down Expand Up @@ -71,4 +72,12 @@ if [ ! -d "$TPM" ]; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi

# Install paq-nvim if not there
PAQ_NVIM=~/.local/share/nvim/site/pack/paqs/opt/paq-nvim
if [ ! -d "$PAQ_NVIM" ]; then
echo -e "🛠 Installing paq-nvim…"
git clone https://github.com/savq/paq-nvim.git \
"${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/pack/paqs/opt/paq-nvim
fi

echo -e $COLOR_GREEN"✅ Done\n"$COLOR_RESET

0 comments on commit 587b7c8

Please sign in to comment.