feat: finalized config
This commit is contained in:
parent
28057baf5f
commit
c341636729
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/plugin/
|
5
init.lua
5
init.lua
@ -1,5 +1,4 @@
|
||||
require('settings')
|
||||
require("keymaps")
|
||||
require('options')
|
||||
require('plugins')
|
||||
require('themes')
|
||||
|
||||
vim.cmd('COQnow -s')
|
||||
|
32
lua/keymaps.lua
Normal file
32
lua/keymaps.lua
Normal file
@ -0,0 +1,32 @@
|
||||
-- source file everytime it changes
|
||||
vim.cmd([[
|
||||
augroup user_keymaps
|
||||
autocmd!
|
||||
autocmd BufWritePost keymaps.lua source <afile>
|
||||
augroup end
|
||||
]])
|
||||
|
||||
local function nnoremap(key, command)
|
||||
vim.api.nvim_set_keymap("n",key,command, { noremap = true, silent = true })
|
||||
end
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- Move around windows
|
||||
nnoremap("<C-h>", "<C-w>h")
|
||||
nnoremap("<C-j>", "<C-w>j")
|
||||
nnoremap("<C-k>", "<C-w>k")
|
||||
nnoremap("<C-l>", "<C-w>l")
|
||||
|
||||
-- Switch buffers
|
||||
nnoremap("<TAB>", ":TablineBufferNext<CR>")
|
||||
nnoremap("<S-TAB>", ":TablineBufferPrevious<CR>")
|
||||
|
||||
-- fugitive
|
||||
nnoremap("<leader>G", ":tab G<CR>")
|
||||
|
||||
-- telescope
|
||||
nnoremap("<leader>ff", "<Cmd>Telescope find_files theme=dropdown<CR>")
|
||||
nnoremap("<leader>fb", "<Cmd>Telescope buffers theme=dropdown<CR>")
|
||||
nnoremap("<leader>fg", "<Cmd>Telescope git_files theme=dropdown<CR>")
|
46
lua/options.lua
Normal file
46
lua/options.lua
Normal file
@ -0,0 +1,46 @@
|
||||
-- source file everytime it changes
|
||||
vim.cmd([[
|
||||
augroup user_options
|
||||
autocmd!
|
||||
autocmd BufWritePost options.lua source <afile>
|
||||
augroup end
|
||||
]])
|
||||
|
||||
-- termguicolors
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
-- line numbers
|
||||
vim.opt.number = true
|
||||
|
||||
-- tabwidth
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
|
||||
-- indent with spaces
|
||||
vim.opt.expandtab = true
|
||||
|
||||
-- scroll offset
|
||||
vim.opt.scrolloff = 4
|
||||
|
||||
-- don't warp lines
|
||||
vim.opt.wrap = false
|
||||
|
||||
-- split to right/below
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
|
||||
-- presistent undo
|
||||
vim.opt.undofile = true
|
||||
|
||||
-- searching
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
|
||||
-- preview commands
|
||||
vim.opt.inccommand = "split"
|
||||
|
||||
-- enable cursorline
|
||||
vim.opt.cursorline = true
|
||||
|
||||
-- coq.nvim
|
||||
vim.g.coq_settings = { auto_start = "shut-up" }
|
156
lua/plugins.lua
156
lua/plugins.lua
@ -1,77 +1,125 @@
|
||||
local fn = vim.fn
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- Boostrap Packer
|
||||
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
|
||||
-- boostrap packer
|
||||
local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim'
|
||||
local packer_bootstrap
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
packer_bootstrap = fn.system({'git', 'clone','https://github.com/wbthomason/packer.nvim', install_path})
|
||||
packer_bootstrap = fn.system({'git', 'clone','https://github.com/wbthomason/packer.nvim', install_path})
|
||||
end
|
||||
|
||||
-- Rerun PackerSync everytime plugins.lua is updated
|
||||
cmd([[
|
||||
-- run PackerSync everytime plugins.lua is updated
|
||||
vim.cmd([[
|
||||
augroup packer_user_config
|
||||
autocmd!
|
||||
autocmd BufWritePost plugins.lua source <afile> | PackerSync
|
||||
augroup end
|
||||
]])
|
||||
|
||||
-- Initialize pluggins
|
||||
vim.cmd([[packadd packer.nvim]])
|
||||
|
||||
-- initialize plugins
|
||||
return require('packer').startup(function(use)
|
||||
-- Let Packer manage itself
|
||||
use('wbthomason/packer.nvim')
|
||||
-- let packer manage itself
|
||||
use({'wbthomason/packer.nvim', opt = true})
|
||||
|
||||
-- Themes
|
||||
use('altercation/vim-colors-solarized')
|
||||
-- theme
|
||||
use("ishan9299/nvim-solarized-lua")
|
||||
|
||||
-- session handling
|
||||
use('tpope/vim-obsession')
|
||||
use('dhruvasagar/vim-prosession')
|
||||
-- commenting
|
||||
use("tpope/vim-commentary")
|
||||
|
||||
-- status line
|
||||
use {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
|
||||
config = function()
|
||||
require('lualine').setup()
|
||||
end
|
||||
}
|
||||
-- session handling
|
||||
use('tpope/vim-obsession')
|
||||
use('dhruvasagar/vim-prosession')
|
||||
|
||||
-- git commands
|
||||
use({
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
config = function ()
|
||||
require("indent_blankline").setup {
|
||||
char = "┊",
|
||||
buftype_exclude = {"terminal", "help"}
|
||||
}
|
||||
end
|
||||
})
|
||||
-- status line
|
||||
use {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
|
||||
config = function()
|
||||
require('lualine').setup()
|
||||
end
|
||||
}
|
||||
|
||||
-- language server
|
||||
use("neovim/nvim-lspconfig")
|
||||
-- tabline
|
||||
use {
|
||||
'kdheepak/tabline.nvim',
|
||||
config = function()
|
||||
require'tabline'.setup {
|
||||
enable = true,
|
||||
options = {
|
||||
show_filename_only = true,
|
||||
}
|
||||
}
|
||||
end,
|
||||
requires = { { 'hoob3rt/lualine.nvim' }, {'kyazdani42/nvim-web-devicons', opt = true} }
|
||||
}
|
||||
|
||||
-- autocompletion
|
||||
use({
|
||||
"ms-jpq/coq_nvim",
|
||||
branch="coq",
|
||||
})
|
||||
use({'ms-jpq/coq.artifacts', branch = 'artifacts'})
|
||||
-- blankline
|
||||
use({
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
config = function ()
|
||||
require("indent_blankline").setup {
|
||||
char = "┊",
|
||||
buftype_exclude = {"terminal", "help"}
|
||||
}
|
||||
end
|
||||
})
|
||||
|
||||
local language_servers = { "bashls", "rls", "sumneko_lua" }
|
||||
for _, server in pairs(language_servers) do
|
||||
require("lspconfig")[server].setup(require("coq").lsp_ensure_capabilities({}))
|
||||
end
|
||||
-- git
|
||||
use('tpope/vim-fugitive')
|
||||
use ({
|
||||
'lewis6991/gitsigns.nvim',
|
||||
requires = {'nvim-lua/plenary.nvim'},
|
||||
config = function() require('gitsigns').setup() end
|
||||
})
|
||||
|
||||
use('tpope/vim-fugitive')
|
||||
use ({
|
||||
'lewis6991/gitsigns.nvim',
|
||||
requires = {'nvim-lua/plenary.nvim'},
|
||||
config = function() require('gitsigns').setup() end
|
||||
})
|
||||
-- autocompletion
|
||||
use({
|
||||
"ms-jpq/coq_nvim",
|
||||
branch="coq",
|
||||
requires = {
|
||||
{'ms-jpq/coq.artifacts', branch = 'artifacts'},
|
||||
},
|
||||
})
|
||||
|
||||
if packer_bootstrap then
|
||||
require('packer').sync()
|
||||
end
|
||||
-- highlight current symbol
|
||||
use({
|
||||
"nvim-treesitter/nvim-treesitter-refactor",
|
||||
config = function () require("nvim-treesitter.configs").setup({
|
||||
refactor = {
|
||||
highlight_definitions = {
|
||||
enable = true,
|
||||
clear_on_cursor_move = true,
|
||||
},
|
||||
}
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- language server
|
||||
use({
|
||||
"neovim/nvim-lspconfig",
|
||||
config = function() require("plugins.lspconfig") end,
|
||||
})
|
||||
|
||||
use('williamboman/nvim-lsp-installer')
|
||||
|
||||
-- treesitter
|
||||
use({
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
config = function() require('plugins.treesitter') end,
|
||||
run = ':TSUpdate'
|
||||
})
|
||||
|
||||
-- Telescope
|
||||
use({
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = {{'nvim-lua/plenary.nvim'}},
|
||||
config = function() require('plugins.telescope') end,
|
||||
})
|
||||
|
||||
if packer_bootstrap then
|
||||
require('packer').sync()
|
||||
end
|
||||
end)
|
||||
|
||||
|
19
lua/plugins/bufferline.lua
Normal file
19
lua/plugins/bufferline.lua
Normal file
@ -0,0 +1,19 @@
|
||||
require('bufferline')
|
||||
|
||||
-- format as "<id>. <file-name>"
|
||||
local tabname_format = function (opts)
|
||||
return string.format('%s.', opts.ordinal)
|
||||
end
|
||||
|
||||
require('bufferline').setup({
|
||||
options = {
|
||||
always_show_bufferline = true,
|
||||
numbers = tabname_format,
|
||||
show_buffer_icons = true,
|
||||
show_buffer_close_icons = false,
|
||||
show_close_icon = false,
|
||||
--separator_style = 'slant',
|
||||
},
|
||||
-- Don't use italic on current buffer
|
||||
highlights = {buffer_selected = { gui = "bold" },},
|
||||
})
|
97
lua/plugins/lspconfig.lua
Normal file
97
lua/plugins/lspconfig.lua
Normal file
@ -0,0 +1,97 @@
|
||||
local coq = require("coq")
|
||||
local lsp_installer = require("nvim-lsp-installer")
|
||||
|
||||
local nvim_runtime_path = vim.split(package.path, ';')
|
||||
table.insert(nvim_runtime_path, "lua/?.lua")
|
||||
table.insert(nvim_runtime_path, "lua/?/init.lua")
|
||||
|
||||
local language_servers = {
|
||||
"ansiblels",
|
||||
"bashls",
|
||||
"dockerls",
|
||||
"eslint",
|
||||
"html",
|
||||
"pyright",
|
||||
"remark_ls",
|
||||
"rust_analyzer",
|
||||
"sumneko_lua",
|
||||
"svelte",
|
||||
"taplo",
|
||||
"tsserver",
|
||||
"volar",
|
||||
}
|
||||
|
||||
for _, server_name in pairs(language_servers) do
|
||||
local server_found, server = lsp_installer.get_server(server_name)
|
||||
if server_found and not server:is_installed() then
|
||||
print("Installing " .. server_name)
|
||||
server:install()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local extra_server_opts = {
|
||||
["sumneko_lua"] = function(opts)
|
||||
opts.settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
path = nvim_runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
globals = {'vim'},
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
telemetry ={
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
local function custom_on_attach(client, buffer_nr)
|
||||
-- Helper function
|
||||
local opts = {noremap = true, silent = true}
|
||||
local function bufnnoremap(key, action)
|
||||
vim.api.nvim_buf_set_keymap(buffer_nr, 'n', key, action, opts)
|
||||
end
|
||||
|
||||
-- Inspect function
|
||||
bufnnoremap("K", "<Cmd>lua vim.lsp.buf.hover()<CR>")
|
||||
|
||||
-- Rename all references of symbol
|
||||
bufnnoremap("<leader>R", "<Cmd>lua vim.lsp.buf.rename()<CR>")
|
||||
|
||||
-- Navigate diagnostics
|
||||
bufnnoremap("<C-n>", "<Cmd>lua vim.diagnostic.goto_next()<CR>")
|
||||
bufnnoremap("<C-p>", "<Cmd>lua vim.diagnostic.goto_prev()<CR>")
|
||||
|
||||
-- Show line diagnostics
|
||||
bufnnoremap("<leader>d", '<Cmd>lua vim.diagnostic.open_float(0, {scope = "line"})<CR>')
|
||||
|
||||
-- Open local diagnostics in local list
|
||||
bufnnoremap("<leader>D", "<Cmd>lua vim.diagnostic.setloclist()<CR>")
|
||||
|
||||
-- Open all project diagnostics in quickfix list
|
||||
bufnnoremap("<leader><C-d>", "<Cmd>lua vim.diagnostic.setqflist()<CR>")
|
||||
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()")
|
||||
end
|
||||
end
|
||||
|
||||
lsp_installer.on_server_ready(function(server)
|
||||
local opts = coq.lsp_ensure_capabilities({
|
||||
on_attach = custom_on_attach,
|
||||
capabilities = vim.lsp.protocol.make_client_capabilities(),
|
||||
})
|
||||
|
||||
if extra_server_opts[server.name] then
|
||||
extra_server_opts[server.name](opts)
|
||||
end
|
||||
|
||||
server:setup(opts)
|
||||
end)
|
12
lua/plugins/telescope.lua
Normal file
12
lua/plugins/telescope.lua
Normal file
@ -0,0 +1,12 @@
|
||||
local actions = require("telescope.actions")
|
||||
|
||||
require('telescope').setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-j>"] = actions.move_selection_next,
|
||||
["<C-k>"] = actions.move_selection_previous,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
21
lua/plugins/treesitter.lua
Normal file
21
lua/plugins/treesitter.lua
Normal file
@ -0,0 +1,21 @@
|
||||
require('nvim-treesitter.configs').setup({
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"cpp",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"python",
|
||||
"rust",
|
||||
"vim",
|
||||
"yaml",
|
||||
},
|
||||
})
|
@ -1,9 +0,0 @@
|
||||
-- source file everytime it changes
|
||||
vim.cmd([[
|
||||
augroup user_settings
|
||||
autocmd!
|
||||
autocmd BufWritePost settings.lua source <afile>
|
||||
augroup end
|
||||
]])
|
||||
|
||||
vim.opt.number = true
|
@ -6,5 +6,5 @@ vim.cmd([[
|
||||
augroup end
|
||||
]])
|
||||
|
||||
vim.cmd [[colorscheme solarized]]
|
||||
vim.opt.background = 'dark'
|
||||
vim.cmd("colorscheme solarized")
|
||||
|
Reference in New Issue
Block a user