first commit
This commit is contained in:
9
lua/colorscheme.lua
Normal file
9
lua/colorscheme.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
-- define your colorscheme here
|
||||
local colorscheme = 'monokai_pro'
|
||||
|
||||
local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
|
||||
if not is_ok then
|
||||
vim.notify('colorscheme ' .. colorscheme .. ' not found!')
|
||||
return
|
||||
end
|
||||
|
||||
80
lua/config/nvim-cmp.lua
Normal file
80
lua/config/nvim-cmp.lua
Normal file
@@ -0,0 +1,80 @@
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local luasnip = require("luasnip")
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
-- Use <C-b/f> to scroll the docs
|
||||
['<C-b>'] = cmp.mapping.scroll_docs( -4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
-- Use <C-k/j> to switch in items
|
||||
['<C-k>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-j>'] = cmp.mapping.select_next_item(),
|
||||
-- Use <CR>(Enter) to confirm selection
|
||||
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
|
||||
-- A super tab
|
||||
-- sourc: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
-- Hint: if the completion menu is visible select next one
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }), -- i - insert mode; s - select mode
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable( -1) then
|
||||
luasnip.jump( -1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
|
||||
-- Let's configure the item's appearance
|
||||
-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance
|
||||
formatting = {
|
||||
-- Set order from left to right
|
||||
-- kind: single letter indicating the type of completion
|
||||
-- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word"
|
||||
-- menu: extra text for the popup menu, displayed after "word" or "abbr"
|
||||
fields = { 'abbr', 'menu' },
|
||||
|
||||
-- customize the appearance of the completion menu
|
||||
format = function(entry, vim_item)
|
||||
vim_item.menu = ({
|
||||
nvim_lsp = '[Lsp]',
|
||||
luasnip = '[Luasnip]',
|
||||
buffer = '[File]',
|
||||
path = '[Path]',
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
|
||||
-- Set source precedence
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
||||
{ name = 'luasnip' }, -- For luasnip user
|
||||
{ name = 'buffer' }, -- For buffer word completion
|
||||
{ name = 'path' }, -- For path completion
|
||||
})
|
||||
})
|
||||
|
||||
50
lua/keymaps.lua
Normal file
50
lua/keymaps.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
-- define common options
|
||||
local opts = {
|
||||
noremap = true, -- non-recursive
|
||||
silent = true, -- do not show message
|
||||
}
|
||||
|
||||
-----------------
|
||||
-- Normal mode --
|
||||
-----------------
|
||||
|
||||
-- Hint: see `:h vim.map.set()`
|
||||
-- Better window navigation
|
||||
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', opts)
|
||||
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', opts)
|
||||
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', opts)
|
||||
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', opts)
|
||||
|
||||
-- Resize with arrows
|
||||
-- delta: 2 lines
|
||||
vim.api.nvim_set_keymap('n', '<C-Up>', ':resize -2<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', '<C-Down>', ':resize +2<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', '<C-Left>', ':vertical resize -2<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', '<C-Right>', ':vertical resize +2<CR>', opts)
|
||||
|
||||
-----------------
|
||||
-- Visual mode --
|
||||
-----------------
|
||||
|
||||
-- Hint: start visual mode with the same area as the previous area and the same mode
|
||||
vim.api.nvim_set_keymap('v', '<', '<gv', opts)
|
||||
vim.api.nvim_set_keymap('v', '>', '>gv', opts)
|
||||
|
||||
|
||||
---------------------
|
||||
-- Mardown Preview --
|
||||
---------------------
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<C-s>', ':MarkdownPreview<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', '<M-s>', ':MarkdownPreviewStop<CR>', opts)
|
||||
vim.api.nvim_set_keymap('i', '<C-s>', ':MarkdownPreview<CR>', opts)
|
||||
vim.api.nvim_set_keymap('i', '<M-s>', ':MarkdownPreviewStop<CR>', opts)
|
||||
|
||||
------------------
|
||||
-- NNN explorer --
|
||||
------------------
|
||||
vim.api.nvim_set_keymap('n', '<C-e>', ':NnnExplorer<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', '<C-p>', ':NnnPicker<CR>', opts)
|
||||
|
||||
vim.api.nvim_set_keymap('i', '<C-l>', '<C-o>:call v:null<CR>', {noremap = true})
|
||||
|
||||
16
lua/lsp.lua
Normal file
16
lua/lsp.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
require('mason').setup({
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
require('mason-lspconfig').setup({
|
||||
-- A list of servers to automatically install if they're not already installed
|
||||
ensure_installed = { 'pylsp', 'gopls', 'lua_ls', 'rust_analyzer', 'clangd' },
|
||||
})
|
||||
|
||||
|
||||
26
lua/options.lua
Normal file
26
lua/options.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
vim.opt.clipboard = 'unnamedplus' -- use system clipboard
|
||||
vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
|
||||
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
|
||||
|
||||
-- Tab
|
||||
vim.opt.tabstop = 4 -- number of visual spaces per TAB
|
||||
vim.opt.softtabstop = 4 -- number of spacesin tab when editing
|
||||
vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab
|
||||
vim.opt.expandtab = true -- tabs are spaces, mainly because of python
|
||||
|
||||
-- UI config
|
||||
vim.opt.number = true -- show absolute number
|
||||
vim.opt.relativenumber = false -- add numbers to each line on the left side
|
||||
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
|
||||
vim.opt.splitbelow = true -- open new vertical split bottom
|
||||
vim.opt.splitright = true -- open new horizontal splits right
|
||||
vim.opt.termguicolors = true -- enable 24-bit RGB color in the TUI
|
||||
vim.opt.showmode = true
|
||||
|
||||
-- Searching
|
||||
vim.opt.incsearch = true -- search as characters are entered
|
||||
vim.opt.hlsearch = false -- do not highlight matches
|
||||
vim.opt.ignorecase = true -- ignore case in searches by default
|
||||
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
|
||||
|
||||
|
||||
74
lua/plugins.lua
Normal file
74
lua/plugins.lua
Normal file
@@ -0,0 +1,74 @@
|
||||
-- Install Packer automatically if it's not installed(Bootstraping)
|
||||
-- Hint: string concatenation is done by `..`
|
||||
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()
|
||||
|
||||
|
||||
-- Reload configurations if we modify plugins.lua
|
||||
-- Hint
|
||||
-- <afile> - replaced with the filename of the buffer being manipulated
|
||||
vim.cmd([[
|
||||
augroup packer_user_config
|
||||
autocmd!
|
||||
autocmd BufWritePost plugins.lua source <afile> | PackerSync
|
||||
augroup end
|
||||
]])
|
||||
|
||||
|
||||
-- Install plugins here - `use ...`
|
||||
-- Packer.nvim hints
|
||||
-- after = string or list, -- Specifies plugins to load before this plugin. See "sequencing" below
|
||||
-- config = string or function, -- Specifies code to run after this plugin is loaded
|
||||
-- requires = string or list, -- Specifies plugin dependencies. See "dependencies".
|
||||
-- ft = string or list, -- Specifies filetypes which load this plugin.
|
||||
-- run = string, function, or table, -- Specify operations to be run after successful installs/updates of a plugin
|
||||
return require('packer').startup(function(use)
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
use 'tanvirtin/monokai.nvim'
|
||||
use {
|
||||
"williamboman/mason.nvim",
|
||||
run = ":MasonUpdate" -- :MasonUpdate updates registry contents
|
||||
}
|
||||
use { 'williamboman/mason-lspconfig.nvim'}
|
||||
|
||||
use { 'neovim/nvim-lspconfig' }
|
||||
use { 'hrsh7th/nvim-cmp', config = [[require('config.nvim-cmp')]] }
|
||||
use { 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' }
|
||||
--use { 'hrsh7th/cmp-buffer', after = 'nvim-cmp' } -- buffer auto-completion
|
||||
use { 'hrsh7th/cmp-path', after = 'nvim-cmp' } -- path auto-completion
|
||||
use { 'hrsh7th/cmp-cmdline', after = 'nvim-cmp' } -- cmdline auto-completion
|
||||
use 'L3MON4D3/LuaSnip'
|
||||
use 'saadparwaiz1/cmp_luasnip'
|
||||
|
||||
use({
|
||||
"iamcco/markdown-preview.nvim",
|
||||
run = function() vim.fn["mkdp#util#install"]() end,
|
||||
})
|
||||
|
||||
-- File manager
|
||||
use {
|
||||
"luukvbaal/nnn.nvim",
|
||||
config = function() require("nnn").setup() end
|
||||
}
|
||||
|
||||
use { 'https://git.richoux.me/tfa/vim-log-highlighting', after = 'nvim-cmp' } -- cmdline auto-completion
|
||||
|
||||
use 'mzlogin/vim-markdown-toc'
|
||||
|
||||
-- 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)
|
||||
|
||||
Reference in New Issue
Block a user