Add nvim config
This commit is contained in:
parent
92366b38ac
commit
df7bfd1282
14 changed files with 285 additions and 0 deletions
8
.config/nvim/after/plugin/colors.lua
Normal file
8
.config/nvim/after/plugin/colors.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
local dracula = require("dracula")
|
||||
dracula.setup({
|
||||
-- show the '~' characters after the end of buffers
|
||||
show_end_of_buffer = true, -- default false
|
||||
-- use transparent background
|
||||
transparent_bg = true, -- default false
|
||||
})
|
||||
vim.cmd('colorscheme dracula')
|
1
.config/nvim/after/plugin/fugitive.lua
Normal file
1
.config/nvim/after/plugin/fugitive.lua
Normal file
|
@ -0,0 +1 @@
|
|||
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
|
68
.config/nvim/after/plugin/lsp.lua
Normal file
68
.config/nvim/after/plugin/lsp.lua
Normal file
|
@ -0,0 +1,68 @@
|
|||
local lsp = require("lsp-zero")
|
||||
|
||||
lsp.preset("recommended")
|
||||
|
||||
lsp.ensure_installed({
|
||||
-- 'bashls',
|
||||
-- 'lua_ls',
|
||||
-- 'pylsp',
|
||||
-- 'rnix',
|
||||
})
|
||||
|
||||
-- Fix Undefined global 'vim'
|
||||
require('lspconfig').lua_ls.setup({
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { 'vim' }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
local cmp = require('cmp')
|
||||
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||
local cmp_mappings = lsp.defaults.cmp_mappings({
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
})
|
||||
|
||||
cmp_mappings['<Tab>'] = nil
|
||||
cmp_mappings['<S-Tab>'] = nil
|
||||
|
||||
lsp.setup_nvim_cmp({
|
||||
mapping = cmp_mappings
|
||||
})
|
||||
|
||||
lsp.set_preferences({
|
||||
suggest_lsp_servers = false,
|
||||
sign_icons = {
|
||||
error = 'E',
|
||||
warn = 'W',
|
||||
hint = 'H',
|
||||
info = 'I'
|
||||
}
|
||||
})
|
||||
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
local opts = { buffer = bufnr, remap = false }
|
||||
|
||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
end)
|
||||
|
||||
lsp.setup()
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true
|
||||
})
|
41
.config/nvim/after/plugin/lualine.lua
Normal file
41
.config/nvim/after/plugin/lualine.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
local function window()
|
||||
return vim.api.nvim_win_get_number(0)
|
||||
end
|
||||
|
||||
require('lualine').setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'dracula',
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||
lualine_c = { {
|
||||
'filename',
|
||||
path = 1,
|
||||
} },
|
||||
lualine_x = { 'encoding', '%<0x%B', 'fileformat' },
|
||||
lualine_y = { 'filetype' },
|
||||
lualine_z = { 'location', window }
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = { 'location', window },
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {
|
||||
lualine_a = { {
|
||||
'tabs',
|
||||
max_length = vim.o.columns / 2,
|
||||
mode = 2
|
||||
} },
|
||||
lualine_b = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
lualine_y = { 'branch' },
|
||||
lualine_z = {}
|
||||
}
|
||||
})
|
6
.config/nvim/after/plugin/swap.lua
Normal file
6
.config/nvim/after/plugin/swap.lua
Normal file
|
@ -0,0 +1,6 @@
|
|||
local swap = require('sibling-swap')
|
||||
swap.setup({
|
||||
use_default_keymaps = true
|
||||
})
|
||||
vim.keymap.set('n', 'g<', swap.swap_with_left, {})
|
||||
vim.keymap.set('n', 'g>', swap.swap_with_right, {})
|
7
.config/nvim/after/plugin/telescope.lua
Normal file
7
.config/nvim/after/plugin/telescope.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
|
||||
vim.keymap.set('n', '<leader>ps', function()
|
||||
builtin.grep_string({ search = vim.fn.input("Grep > ") })
|
||||
end)
|
||||
vim.keymap.set('n', '<leader>vh', builtin.help_tags, {})
|
21
.config/nvim/after/plugin/treesitter.lua
Normal file
21
.config/nvim/after/plugin/treesitter.lua
Normal file
|
@ -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" },
|
||||
|
||||
-- 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,
|
||||
},
|
||||
}
|
1
.config/nvim/after/plugin/undotree.lua
Normal file
1
.config/nvim/after/plugin/undotree.lua
Normal file
|
@ -0,0 +1 @@
|
|||
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
1
.config/nvim/init.lua
Normal file
1
.config/nvim/init.lua
Normal file
|
@ -0,0 +1 @@
|
|||
require("user")
|
4
.config/nvim/lua/user/init.lua
Normal file
4
.config/nvim/lua/user/init.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
require("user.set")
|
||||
require("user.remap")
|
||||
|
||||
require("user.packer")
|
65
.config/nvim/lua/user/packer.lua
Normal file
65
.config/nvim/lua/user/packer.lua
Normal file
|
@ -0,0 +1,65 @@
|
|||
-- This file can be loaded by calling `lua require('plugins')` from your init.vim
|
||||
|
||||
-- Only required if you have packer configured as `opt`
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
|
||||
return require('packer').startup(function(use)
|
||||
-- Packer can manage itself
|
||||
use('wbthomason/packer.nvim')
|
||||
|
||||
use({
|
||||
'nvim-telescope/telescope.nvim',
|
||||
tag = '0.1.0',
|
||||
requires = { { 'nvim-lua/plenary.nvim' } }
|
||||
})
|
||||
|
||||
use({
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = ':TSUpdate'
|
||||
})
|
||||
|
||||
use("mbbill/undotree")
|
||||
use("Wansmer/sibling-swap.nvim")
|
||||
|
||||
use({
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v1.x',
|
||||
requires = {
|
||||
-- LSP Support
|
||||
{ 'neovim/nvim-lspconfig' },
|
||||
{ 'williamboman/mason.nvim' },
|
||||
{ 'williamboman/mason-lspconfig.nvim' },
|
||||
|
||||
-- Autocompletion
|
||||
{ 'hrsh7th/nvim-cmp' },
|
||||
{ 'hrsh7th/cmp-buffer' },
|
||||
{ 'hrsh7th/cmp-path' },
|
||||
{ 'saadparwaiz1/cmp_luasnip' },
|
||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||
{ 'hrsh7th/cmp-nvim-lua' },
|
||||
|
||||
-- Snippets
|
||||
{ 'L3MON4D3/LuaSnip' },
|
||||
{ 'rafamadriz/friendly-snippets' },
|
||||
}
|
||||
})
|
||||
|
||||
use({
|
||||
'lewis6991/gitsigns.nvim',
|
||||
config = function()
|
||||
require('gitsigns').setup()
|
||||
end
|
||||
})
|
||||
|
||||
use({
|
||||
'nvim-lualine/lualine.nvim',
|
||||
requires = { 'nvim-tree/nvim-web-devicons', opt = true }
|
||||
})
|
||||
|
||||
use('Mofiqul/dracula.nvim')
|
||||
|
||||
local wakatime_api_key = os.getenv("WAKATIME_API_KEY")
|
||||
if wakatime_api_key then
|
||||
use('wakatime/vim-wakatime')
|
||||
end
|
||||
end)
|
26
.config/nvim/lua/user/remap.lua
Normal file
26
.config/nvim/lua/user/remap.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
vim.g.mapleader = " "
|
||||
|
||||
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
|
||||
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
||||
-- keep cursor centered in screen
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz")
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz")
|
||||
vim.keymap.set("n", "n", "nzzzv")
|
||||
vim.keymap.set("n", "N", "Nzzzv")
|
||||
|
||||
-- paste, but don't overwrite buffer
|
||||
vim.keymap.set("x", "<leader>p", "\"_dP")
|
||||
|
||||
vim.keymap.set("n", "<CR>", "<cmd>noh<CR><CR>")
|
||||
|
||||
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format)
|
||||
|
||||
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
|
||||
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
|
||||
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
|
||||
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
|
||||
|
||||
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
34
.config/nvim/lua/user/set.lua
Normal file
34
.config/nvim/lua/user/set.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
vim.opt.guicursor = ""
|
||||
|
||||
vim.opt.nu = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.expandtab = false
|
||||
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.splitright = true
|
||||
|
||||
vim.opt.smartindent = true
|
||||
|
||||
vim.opt.wrap = false
|
||||
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.cache/vim/undo"
|
||||
vim.opt.undofile = true
|
||||
|
||||
vim.opt.hlsearch = true
|
||||
vim.opt.incsearch = true
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.isfname:append("@-@")
|
||||
|
||||
vim.opt.updatetime = 50
|
||||
|
||||
vim.opt.colorcolumn = "80"
|
2
.config/nvim/plugin/.gitignore
vendored
Normal file
2
.config/nvim/plugin/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
Loading…
Reference in a new issue