summaryrefslogtreecommitdiff
path: root/.config/nvim
diff options
context:
space:
mode:
authoradamstuck <adam.moloney.stuck@gmail.com>2021-10-11 12:57:12 +0200
committeradamstuck <adam.moloney.stuck@gmail.com>2021-10-11 12:57:12 +0200
commit0f1e82e9130acdb63e985548b750383bacc70df9 (patch)
tree85cd7524cded1fe8eecf750280e80d7ab575521d /.config/nvim
parentd7d28a71cec270d00742c9037a109ffa4040933c (diff)
Setup nvim on laptop
Diffstat (limited to '.config/nvim')
-rw-r--r--.config/nvim/init.vim78
-rw-r--r--.config/nvim/lua/after.lua6
-rw-r--r--.config/nvim/lua/binds.lua44
-rw-r--r--.config/nvim/lua/init.lua5
-rw-r--r--.config/nvim/lua/opts.lua143
-rw-r--r--.config/nvim/lua/plugins.lua69
-rw-r--r--.config/nvim/lua/setup.lua32
-rw-r--r--.config/nvim/lua/stl.lua27
8 files changed, 354 insertions, 50 deletions
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim
index ed02ddf..d416e94 100644
--- a/.config/nvim/init.vim
+++ b/.config/nvim/init.vim
@@ -1,60 +1,38 @@
if has('filetype')
- filetype indent plugin on
+ filetype indent plugin on
endif
if has('syntax')
- syntax on
+ syntax on
endif
if has('mouse')
- set mouse=a
+ set mouse=a
endif
-set hidden
-set wildmenu
-set showcmd
-set hlsearch
-set ignorecase
-set smartcase
-set backspace=indent,eol,start
-set autoindent
-set nostartofline
-set ruler
-set laststatus=0
-set confirm
-set visualbell
-set cmdheight=2
-set number
-set relativenumber
-set notimeout ttimeout ttimeoutlen=200
-set pastetoggle=<F11>
-set shiftwidth=4
-set softtabstop=4
-set expandtab
-set incsearch
-
-map Y y$
-nnoremap <C-L> :nohl<CR><C-L>
-nnoremap n nzzzv
-nnoremap N Nzzzv
-
-" inoremap kj <Esc>
-inoremap , ,<c-g>u
-inoremap . .<c-g>u
-inoremap [ [<c-g>u
-inoremap ! !<c-g>u
-inoremap ? ?<c-g>u
-
-nnoremap <expr> k (v:count > 5 ? "m'" . v:count : "") . 'k'
-nnoremap <expr> j (v:count > 5 ? "m'" . v:count : "") . 'j'
-nnoremap <SPACE> <Nop>
-
-call plug#begin()
-Plug 'gruvbox-community/gruvbox'
-call plug#end()
-
-colorscheme gruvbox
-highlight CursorLineNr cterm=bold ctermfg=Yellow ctermbg=none
-highlight Normal ctermbg=none
+if has('persistent_undo')
+ set undodir=$HOME/.vim/undo
+ set undofile
+endif
-let mapleader=" "
+lua require 'init'
+lua require 'after'
+
+let g:ascii = [
+ \ '',
+ \ ' @@@@@@ @@@@@@@ @@@@@@ @@@@@@@@@@ @@@@@@ @@@ @@@ @@@ ',
+ \ ' @@@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@@@@ @@@@@@@ @@@ @@@ @@@ ',
+ \ ' @@! @@@ @@! @@@ @@! @@@ @@! @@! @@! !@@ @@! !@@ @@! ',
+ \ ' !@! @!@ !@! @!@ !@! @!@ !@! !@! !@! !@! !@! @!! !@! ',
+ \ ' @!@!@!@! @!@ !@! @!@!@!@! @!! !!@ @!@ !!@@!! @!@@!@! !!@ ',
+ \ ' !!!@!!!! !@! !!! !!!@!!!! !@! ! !@! !!@!!! !!@!!! !!! ',
+ \ ' !!: !!! !!: !!! !!: !!! !!: !!: !:! !!: :!! !!: ',
+ \ ' :!: !:! :!: !:! :!: !:! :!: :!: !:! :!: !:! :!: ',
+ \ ' :: ::: :::: :: :: ::: ::: :: :::: :: :: ::: :: ',
+ \ ' : : : :: : : : : : : : :: : : : ::: : ',
+ \ '',
+ \ '',
+ \]
+let g:startify_custom_header = startify#pad(g:ascii)
+
+" autocmd FileType markdown lua require('cmp').setup.buffer { enabled = false }
diff --git a/.config/nvim/lua/after.lua b/.config/nvim/lua/after.lua
new file mode 100644
index 0000000..454acee
--- /dev/null
+++ b/.config/nvim/lua/after.lua
@@ -0,0 +1,6 @@
+require'colorizer'.setup {
+ '*';
+ '!vim';
+ css = { rgb_fn = true; };
+ html = { names = false; }
+}
diff --git a/.config/nvim/lua/binds.lua b/.config/nvim/lua/binds.lua
new file mode 100644
index 0000000..181391e
--- /dev/null
+++ b/.config/nvim/lua/binds.lua
@@ -0,0 +1,44 @@
+vim.g.mapleader = ' '
+vim.b.mapleader = ' '
+
+local map = vim.api.nvim_set_keymap
+local opts = { noremap = true, silent = true }
+
+map('', 'Y', 'y$', opts)
+map('n', '<C-L>', ':nohl<CR><C-L>', opts)
+map('n', 'n', 'nzzzv', opts)
+map('n', 'N', 'Nzzzv', opts)
+map('i', 'kj', '<Esc>', opts)
+map('t', 'kj', '<C-\\><C-n>', { noremap = true })
+
+map('i', ',', ',<c-g>u', opts)
+map('i', '.', '.<c-g>u', opts)
+map('i', '[', '[<c-g>u', opts)
+map('i', '!', '!<c-g>u', opts)
+map('i', '?', '?<c-g>u', opts)
+
+map('v', '<A-j>', ":m '>+1<CR>gv=gv", opts)
+map('v', '<A-k>', ":m '<-2<CR>gv=gv", opts)
+
+map('n', '<leader>h', ':wincmd h<CR>', opts)
+map('n', '<leader>j', ':wincmd j<CR>', opts)
+map('n', '<leader>k', ':wincmd k<CR>', opts)
+map('n', '<leader>l', ':wincmd l<CR>', opts)
+
+map('n', '<C-n>', ':NvimTreeToggle<CR>', opts)
+map('n', '<leader>n', ':NvimTreeFindFile<CR>', opts)
+
+map('n', '<C-p>', '<cmd>Telescope find_files<cr>', opts)
+map('n', '<leader>fg', '<cmd>Telescope live_grep<cr>', opts)
+map('n', '<leader>fb', '<cmd>Telescope buffers<cr>', opts)
+map('n', '<leader>fh', '<cmd>Telescope help_tags<cr>', opts)
+
+map('n', '<leader>fu', '<cmd>Telescope lsp_references<cr>', opts)
+map('n', '<leader>gd', '<cmd>Telescope lsp_definitions<cr>', opts)
+map('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
+map('n', '<leader>xd', '<cmd>Telescope lsp_document_diagnostics<cr>', opts)
+map('n', '<leader>xD', '<cmd>Telescope lsp_workspace_diagnostics<cr>', opts)
+map('n', '<leader>xn', '<cmd>lua vim.lsp.diagnostic.goto_next()<cr>', opts)
+map('n', '<leader>xN', '<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>', opts)
+map('n', '<leader>xx', '<cmd>Telescope lsp_code_actions<cr>', opts)
+map('n', '<leader>xX', '<cmd>Telescope lsp_range_code_actions<cr>', opts)
diff --git a/.config/nvim/lua/init.lua b/.config/nvim/lua/init.lua
new file mode 100644
index 0000000..3bc3238
--- /dev/null
+++ b/.config/nvim/lua/init.lua
@@ -0,0 +1,5 @@
+require('plugins')
+require('opts')
+require('setup')
+require('binds')
+require('stl')
diff --git a/.config/nvim/lua/opts.lua b/.config/nvim/lua/opts.lua
new file mode 100644
index 0000000..21f69fd
--- /dev/null
+++ b/.config/nvim/lua/opts.lua
@@ -0,0 +1,143 @@
+local nvim_lsp = require('lspconfig')
+local capabilities = vim.lsp.protocol.make_client_capabilities()
+capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
+
+local servers = { 'omnisharp', 'html', 'sumneko_lua', 'bashls', 'tsserver', 'cssls' }
+for _, lsp in ipairs(servers) do
+ nvim_lsp[lsp].setup {
+ capabilities = capabilities,
+ }
+end
+
+vim.o.completeopt = 'menuone,noselect'
+
+-- CMP
+local cmp = require 'cmp'
+
+local t = function(str)
+ return vim.api.nvim_replace_termcodes(str, true, true, true)
+end
+
+cmp.setup {
+ snippet = {
+ expand = function(args)
+ vim.fn["UltiSnips#Anon"](args.body)
+ end,
+ },
+ mapping = {
+ ['<C-n>'] = cmp.mapping.select_next_item(),
+ ['<C-p>'] = cmp.mapping.select_prev_item(),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-d>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-e>'] = cmp.mapping.close(),
+ ['<CR>'] = cmp.mapping.confirm {
+ behavior = cmp.ConfirmBehavior.Replace,
+ select = true,
+ },
+ ["<Tab>"] = cmp.mapping(function(fallback)
+ if vim.fn["UltiSnips#CanJumpForwards"]() == 1 then
+ vim.fn.feedkeys(t("<ESC>:call UltiSnips#JumpForwards()<CR>"))
+ else
+ fallback()
+ end
+ end, { "i", "s", }),
+ ["<S-Tab>"] = cmp.mapping(function(fallback)
+ if vim.fn["UltiSnips#CanJumpBackwards"]() == 1 then
+ return vim.fn.feedkeys(t("<ESC>:call UltiSnips#JumpBackwards()<CR>"))
+ else
+ fallback()
+ end
+ end, { "i", "s", }),
+ },
+ sources = {
+ { name = 'nvim_lsp' },
+ { name = 'ultisnips' },
+ },
+}
+
+-- C#
+local pid = vim.fn.getpid()
+
+require 'lspconfig'.omnisharp.setup {
+ capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
+ on_attach = function(_, bufnr)
+ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
+ end,
+ cmd = { "/usr/bin/omnisharp", "--languageserver" , "--hostPID", tostring(pid) },
+}
+
+-- LUA
+local sumneko_root_path = "/home/adam/Documents/github/lua-language-server"
+local sumneko_binary = sumneko_root_path.."/bin/Linux/lua-language-server"
+
+local runtime_path = vim.split(package.path, ';')
+table.insert(runtime_path, "lua/?.lua")
+table.insert(runtime_path, "lua/?/init.lua")
+
+require'lspconfig'.sumneko_lua.setup {
+ cmd = {sumneko_binary, "-E", sumneko_root_path.."/main.lua"};
+ settings = {
+ Lua = {
+ runtime = {
+ version = 'LuaJIT',
+ path = runtime_path,
+ },
+ diagnostics = {
+ globals = {'vim'},
+ },
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+ telemetry = {
+ enable = false,
+ },
+ },
+ },
+}
+
+require'lsp_signature'.setup {
+ cfg = {
+ floating_window = true,
+ floating_window_above_cur_line = true,
+ fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters
+ hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight
+ max_height = 12,
+ max_width = 120,
+ handler_opts = {
+ border = "single" -- double, single, shadow, none
+ },
+ extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","}
+ zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom
+ padding = '', -- character to pad on left and right of signature can be ' ', or '|' etc
+ timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency
+ toggle_key = nil -- toggle signature on and off in insert mode, e.g. toggle_key = '<M-x>'
+ }
+}
+
+-- HTML, CSS, JS (TS), BASH
+require'lspconfig'.html.setup{}
+require'lspconfig'.cssls.setup{}
+require'lspconfig'.tsserver.setup{}
+require'lspconfig'.bashls.setup{}
+
+-- Treesitter
+require'nvim-treesitter.configs'.setup {
+ highlight = {
+ enable = true,
+ },
+}
+
+require("toggleterm").setup{
+ -- size can be a number or function which is passed the current terminal
+ size = 65,
+ open_mapping = [[<c-\>]],
+ hide_numbers = true, -- hide the number column in toggleterm buffers
+ persist_size = true,
+ direction = 'vertical',
+ close_on_exit = true, -- close the terminal window when the process exits
+}
+
+-- Misc
+require "lsp_signature".setup()
+require('kommentary.config').use_extended_mappings()
+vim.o.tabline = '%!v:lua.require\'luatab\'.tabline()'
diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua
new file mode 100644
index 0000000..29eb25a
--- /dev/null
+++ b/.config/nvim/lua/plugins.lua
@@ -0,0 +1,69 @@
+local use = require('packer').use
+require('packer').startup(function()
+ use 'wbthomason/packer.nvim'
+ use 'gruvbox-community/gruvbox'
+ use 'tomasiser/vim-code-dark'
+ use 'tpope/vim-fugitive'
+ use 'tpope/vim-surround'
+ use 'ThePrimeagen/vim-be-good'
+ use 'neovim/nvim-lspconfig'
+ use 'hrsh7th/nvim-cmp'
+ use 'hrsh7th/cmp-nvim-lsp'
+ use 'hrsh7th/cmp-buffer'
+ use 'hrsh7th/cmp-path'
+ use 'kyazdani42/nvim-web-devicons'
+ use 'norcalli/nvim-colorizer.lua'
+ use 'b3nj5m1n/kommentary'
+ use 'mhinz/vim-startify'
+ use "akinsho/toggleterm.nvim"
+ use "ray-x/lsp_signature.nvim"
+
+ use {
+ 'nvim-telescope/telescope.nvim',
+ requires = {
+ 'nvim-lua/popup.nvim',
+ 'nvim-lua/plenary.nvim',
+ 'nvim-telescope/telescope-fzy-native.nvim',
+ 'BurntSushi/ripgrep'
+ }
+ }
+
+ use {
+ "SirVer/ultisnips",
+ requires = {
+ "honza/vim-snippets",
+ "quangnguyen30192/cmp-nvim-ultisnips"
+ },
+ config = function()
+ vim.g.UltiSnipsRemoveSelectModeMappings = 0
+ end,
+ }
+
+ use {
+ 'lewis6991/gitsigns.nvim',
+ requires = {
+ 'nvim-lua/plenary.nvim'
+ },
+ config = function()
+ require('gitsigns').setup()
+ end
+ }
+
+ use {
+ 'nvim-treesitter/nvim-treesitter',
+ run = ':TSUpdate'
+ }
+
+ use { 'alvarosevilla95/luatab.nvim', requires='kyazdani42/nvim-web-devicons' }
+
+ use {
+ 'hoob3rt/lualine.nvim',
+ requires = {'kyazdani42/nvim-web-devicons', opt = true}
+ }
+
+ use {
+ 'kyazdani42/nvim-tree.lua',
+ requires = 'kyazdani42/nvim-web-devicons',
+ config = function() require'nvim-tree'.setup {} end
+ }
+end)
diff --git a/.config/nvim/lua/setup.lua b/.config/nvim/lua/setup.lua
new file mode 100644
index 0000000..5f9cd4f
--- /dev/null
+++ b/.config/nvim/lua/setup.lua
@@ -0,0 +1,32 @@
+local set = vim.opt
+
+set.termguicolors = true
+set.hidden = true
+set.wildmenu = true
+set.wildignorecase = true
+set.fileignorecase = true
+set.showcmd = true
+set.hlsearch = true
+set.ignorecase = true
+set.smartcase = true
+set.incsearch = true
+set.backspace= 'indent,eol,start'
+set.pastetoggle = '<F11>'
+set.confirm = true
+set.number = true
+set.relativenumber = true
+set.shiftwidth = 4
+set.softtabstop = 4
+set.autoindent = true
+set.expandtab = true
+set.showmode = false
+set.ruler = false
+set.timeout = false
+set.ttimeoutlen = 200
+set.wrap = false
+set.fcs = 'eob: '
+set.swapfile = false
+
+vim.cmd('colorscheme gruvbox')
+vim.cmd('highlight CursorLineNr cterm=bold ctermfg=Yellow ctermbg=none')
+vim.cmd('highlight Normal ctermbg=none')
diff --git a/.config/nvim/lua/stl.lua b/.config/nvim/lua/stl.lua
new file mode 100644
index 0000000..f751506
--- /dev/null
+++ b/.config/nvim/lua/stl.lua
@@ -0,0 +1,27 @@
+require'lualine'.setup {
+ options = {
+ icons_enabled = true,
+ theme = 'gruvbox',
+ component_separators = {'', ''},
+ section_separators = {'', ''},
+ disabled_filetypes = {'startify', 'NvimTree', 'toggleterm'}
+ },
+ sections = {
+ lualine_a = {'mode'},
+ lualine_b = {'branch'},
+ lualine_c = {'filename'},
+ lualine_x = {'encoding', '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 = {}
+}