Skip to content

Instantly share code, notes, and snippets.

@maacpiash
Last active July 21, 2022 16:52
Show Gist options
  • Save maacpiash/6a502ed4b907835160ba7ff46f0a5296 to your computer and use it in GitHub Desktop.
Save maacpiash/6a502ed4b907835160ba7ff46f0a5296 to your computer and use it in GitHub Desktop.
Neovim configuration

File structure of ~/.config/nvim:

.
├── coc-settings.json
├── init.lua
├── lua
│   ├── barb.lua
│   ├── keys.lua
│   ├── opts.lua
│   ├── plug.lua
│   └── vars.lua
└── site
    └── pack
        └── packer
            └── start
                └── packer.nvim
                    ├── doc
                    │   └── packer.txt
                    ├── Dockerfile
                    ├── LICENSE
                    ├── lua
                    │   ├── packer
                    │   │   ├── async.lua
                    │   │   ├── clean.lua
                    │   │   ├── compile.lua
                    │   │   ├── display.lua
                    │   │   ├── handlers.lua
                    │   │   ├── install.lua
                    │   │   ├── jobs.lua
                    │   │   ├── load.lua
                    │   │   ├── log.lua
                    │   │   ├── luarocks.lua
                    │   │   ├── plugin_types
                    │   │   │   ├── git.lua
                    │   │   │   └── local.lua
                    │   │   ├── plugin_types.lua
                    │   │   ├── plugin_utils.lua
                    │   │   ├── result.lua
                    │   │   ├── snapshot.lua
                    │   │   ├── update.lua
                    │   │   └── util.lua
                    │   └── packer.lua
                    ├── Makefile
                    ├── README.md
                    ├── selene.toml
                    ├── stylua.toml
                    ├── tests
                    │   ├── helpers.lua
                    │   ├── local_plugin_spec.lua
                    │   ├── minimal.vim
                    │   ├── packer_plugin_utils_spec.lua
                    │   ├── packer_use_spec.lua
                    │   ├── plugin_utils_spec.lua
                    │   └── snapshot_spec.lua
                    └── vim.toml
-- Set barbar's options
require'bufferline'.setup {
-- Enable/disable animations
animation = true,
-- Enable/disable auto-hiding the tab bar when there is a single buffer
auto_hide = false,
-- Enable/disable current/total tabpages indicator (top right corner)
tabpages = true,
-- Enable/disable close button
closable = true,
-- Enables/disable clickable tabs
-- - left-click: go to buffer
-- - middle-click: delete buffer
clickable = true,
-- Excludes buffers from the tabline
-- exclude_ft = {'javascript'},
-- exclude_name = {'package.json'},
-- Enable/disable icons
-- if set to 'numbers', will show buffer index in the tabline
-- if set to 'both', will show buffer index and icons in the tabline
icons = true,
-- If set, the icon color will follow its corresponding buffer
-- highlight group. By default, the Buffer*Icon group is linked to the
-- Buffer* group (see Highlighting below). Otherwise, it will take its
-- default value as defined by devicons.
icon_custom_colors = false,
-- Configure icons on the bufferline.
icon_separator_active = '▎',
icon_separator_inactive = '▎',
icon_close_tab = '',
icon_close_tab_modified = '●',
icon_pinned = '車',
-- If true, new buffers will be inserted at the start/end of the list.
-- Default is to insert after current buffer.
insert_at_end = false,
insert_at_start = false,
-- Sets the maximum padding width with which to surround each tab
maximum_padding = 1,
-- Sets the maximum buffer name length.
maximum_length = 30,
-- If set, the letters for each buffer in buffer-pick mode will be
-- assigned based on their name. Otherwise or in case all letters are
-- already assigned, the behavior is to assign letters in order of
-- usability (see order below)
semantic_letters = true,
-- New buffer letters are assigned in this order. This order is
-- optimal for the qwerty keyboard layout but might need adjustement
-- for other layouts.
letters = 'asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP',
-- Sets the name of unnamed buffers. By default format is "[Buffer X]"
-- where X is the buffer number. But only a static string is accepted here.
no_name_title = nil,
}
{
"coc.preferences.formatOnSaveFiletypes": ["typescript", "typescriptreact"]
}
-- IMPORTS
require('vars') -- Variables
require('opts') -- Options
require('keys') -- Keymaps
require('plug') -- Plugins
require('barb') -- Barbar
require('neo-tree').setup{}
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {},
always_divide_middle = true,
globalstatus = false,
},
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 = {}
}
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
-- barbar
-- Move to previous/next
map('n', '<A-,>', '<Cmd>BufferPrevious<CR>', opts)
map('n', '<A-.>', '<Cmd>BufferNext<CR>', opts)
-- Re-order to previous/next
map('n', '<A-<>', '<Cmd>BufferMovePrevious<CR>', opts)
map('n', '<A->>', '<Cmd>BufferMoveNext<CR>', opts)
-- Goto buffer in position...
map('n', '<A-1>', '<Cmd>BufferGoto 1<CR>', opts)
map('n', '<A-2>', '<Cmd>BufferGoto 2<CR>', opts)
map('n', '<A-3>', '<Cmd>BufferGoto 3<CR>', opts)
map('n', '<A-4>', '<Cmd>BufferGoto 4<CR>', opts)
map('n', '<A-5>', '<Cmd>BufferGoto 5<CR>', opts)
map('n', '<A-6>', '<Cmd>BufferGoto 6<CR>', opts)
map('n', '<A-7>', '<Cmd>BufferGoto 7<CR>', opts)
map('n', '<A-8>', '<Cmd>BufferGoto 8<CR>', opts)
map('n', '<A-9>', '<Cmd>BufferGoto 9<CR>', opts)
map('n', '<A-0>', '<Cmd>BufferLast<CR>', opts)
-- Pin/unpin buffer
map('n', '<A-p>', '<Cmd>BufferPin<CR>', opts)
-- Close buffer
map('n', '<A-c>', '<Cmd>BufferClose<CR>', opts)
-- Wipeout buffer
-- :BufferWipeout
-- Close commands
-- :BufferCloseAllButCurrent
-- :BufferCloseAllButPinned
-- :BufferCloseAllButCurrentOrPinned
-- :BufferCloseBuffersLeft
-- :BufferCloseBuffersRight
-- Magic buffer-picking mode
map('n', '<C-p>', '<Cmd>BufferPick<CR>', opts)
-- Sort automatically by...
map('n', '<Space>bb', '<Cmd>BufferOrderByBufferNumber<CR>', opts)
map('n', '<Space>bd', '<Cmd>BufferOrderByDirectory<CR>', opts)
map('n', '<Space>bl', '<Cmd>BufferOrderByLanguage<CR>', opts)
map('n', '<Space>bw', '<Cmd>BufferOrderByWindowNumber<CR>', opts)
-- Other:
-- :BarbarEnable - enables barbar (enabled by default)
-- :BarbarDisable - very bad command, should never be used
local opt = vim.opt
-- [[ Context ]]
opt.colorcolumn = '120' -- str: Show col for max line length
opt.number = true -- bool: Show line numbers
opt.relativenumber = true -- bool: Show relative line numbers
opt.scrolloff = 4 -- int: Min num lines of context
opt.signcolumn = "yes" -- str: Show the sign column
-- [[ Filetypes ]]
opt.encoding = 'utf8' -- str: String encoding to use
opt.fileencoding = 'utf8' -- str: File encoding to use
-- [[ Theme ]]
opt.syntax = "ON" -- str: Allow syntax highlighting
opt.termguicolors = true -- bool: If term supports ui color then enable
-- [[ Search ]]
opt.ignorecase = true -- bool: Ignore case in search patterns
opt.smartcase = true -- bool: Override ignorecase if search contains capitals
opt.incsearch = true -- bool: Use incremental search
opt.hlsearch = false -- bool: Highlight search matches
-- [[ Whitespace ]]
opt.expandtab = true -- bool: Use spaces instead of tabs
opt.shiftwidth = 4 -- num: Size of an indent
opt.softtabstop = 4 -- num: Number of spaces tabs count for in insert mode
opt.tabstop = 4 -- num: Number of spaces tabs count for
-- [[ Splits ]]
opt.splitright = true -- bool: Place new window to right of current one
opt.splitbelow = true -- bool: Place new window below the current one
return require('packer').startup(function()
use 'wbthomason/packer.nvim' -- so packer can update itself
use { -- nice interface for LSP functions (among other things)
'nvim-telescope/telescope.nvim',
requires = { 'nvim-lua/plenary.nvim' }
}
-- Unless you are still migrating, remove the deprecated commands from v1.x
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
use { -- filesystem navigation
"nvim-neo-tree/neo-tree.nvim",
branch = "v2.x",
requires = {
"nvim-lua/plenary.nvim",
"kyazdani42/nvim-web-devicons", -- filesystem icons
"MunifTanjim/nui.nvim",
}
}
use 'neovim/nvim-lspconfig' -- native LSP support
use 'hrsh7th/nvim-cmp' -- autocompletion framework
use 'hrsh7th/cmp-nvim-lsp' -- LSP autocompletion provider
use 'majutsushi/tagbar' -- code structure
use 'Yggdroot/indentLine' -- see indentation
use 'tpope/vim-fugitive' -- git integration
use 'junegunn/gv.vim' -- commit history
use 'windwp/nvim-autopairs' -- auto close brackets, etc.
use {
'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
}
use 'martinsione/darkplus.nvim' -- dark VS theme
use { 'neoclide/coc.nvim', branch = 'release' } -- Concquer of Completion
use 'OmniSharp/omnisharp-vim'
use 'tpope/vim-commentary'
use 'voldikss/vim-floaterm'
use {
'romgrk/barbar.nvim',
requires = { 'kyazdani42/nvim-web-devicons' }
}
-- autocomplete config
local cmp = require 'cmp'
cmp.setup {
mapping = {
['<Tab>'] = cmp.mapping.select_next_item(),
['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
})
},
sources = {
{ name = 'nvim_lsp' },
}
}
end)
local g = vim.g
g.t_co = 256
g.background = "dark"
g.mapleader = ","
g.localleader = "\\"
g.OmniSharp_server_use_net6 = 1
vim.cmd[[colorscheme darkplus]]
-- Update the packpath
local packer_path = vim.fn.stdpath('config') .. '/site'
vim.o.packpath = vim.o.packpath .. ',' .. packer_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment