Compare commits
33 commits
be5c0939a5
...
9e53067078
Author | SHA1 | Date | |
---|---|---|---|
9e53067078 | |||
93936d00ae | |||
c268319adb | |||
cf88166128 | |||
a898b5e555 | |||
031b4ab737 | |||
da298002ff | |||
51ac294e33 | |||
d94b3b6aec | |||
a662702be3 | |||
3758670e5b | |||
ebb90199fc | |||
9f75d943b3 | |||
34d4f6f109 | |||
ad5f634ba5 | |||
ca122389bd | |||
bf4ca036ac | |||
b128903bfb | |||
82abed7e25 | |||
c2b952b9ce | |||
3f710f51de | |||
c7630d48f8 | |||
0b3168295c | |||
ebcba42537 | |||
cefce76d7a | |||
4388ee491d | |||
28d1ed543a | |||
ce8405840f | |||
4a48c7c83e | |||
6d817ca1bf | |||
dd24be7b17 | |||
e3d10fa2b4 | |||
e91b841e90 |
6 changed files with 286 additions and 0 deletions
2
nvim/.config/nvim/.gitignore
vendored
Normal file
2
nvim/.config/nvim/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
plugin/
|
||||
!after/plugin/
|
89
nvim/.config/nvim/after/plugin/lsp.lua
Normal file
89
nvim/.config/nvim/after/plugin/lsp.lua
Normal file
|
@ -0,0 +1,89 @@
|
|||
-- Custom LSP configuration
|
||||
-- This cannot be done in the config function from Packer
|
||||
-- because it somehow does not work well with make_client_capabilities()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = { "rust_analyzer" }
|
||||
})
|
||||
|
||||
local opts = { noremap=true, silent=true }
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||
|
||||
local cmp = require 'cmp'
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
},
|
||||
})
|
||||
|
||||
-- Rewrite LSP capabilities (to enable completion)
|
||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
|
||||
end
|
||||
|
||||
require('lspconfig')['rust_analyzer'].setup({
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
['rust_analyzer'] = {
|
||||
cargo = {
|
||||
autoreload = true,
|
||||
buildScripts = { enable = true },
|
||||
},
|
||||
procMacro = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
-- TODO: Set this to OFF when neovim supports it (0.8 release probably)
|
||||
-- rust_analyzer spits out spurious errors with build.rs outputs
|
||||
-- likely due to a race condition between the VFS initialization and the diagnostics
|
||||
vim.lsp.set_log_level("error")
|
8
nvim/.config/nvim/ginit.vim
Normal file
8
nvim/.config/nvim/ginit.vim
Normal file
|
@ -0,0 +1,8 @@
|
|||
" Mouse
|
||||
set mouse=a
|
||||
|
||||
" Set Editor Font
|
||||
GuiFont! FiraCode Nerd Font Mono:h10.5:l
|
||||
|
||||
" Ligature
|
||||
GuiRenderLigatures 1
|
57
nvim/.config/nvim/init.vim
Normal file
57
nvim/.config/nvim/init.vim
Normal file
|
@ -0,0 +1,57 @@
|
|||
" Packer plugins
|
||||
lua require('plugins')
|
||||
|
||||
" Gruvbox Theme (colorscheme applied from plugins.lua)
|
||||
if has('termguicolors')
|
||||
set termguicolors
|
||||
endif
|
||||
" For dark version.
|
||||
set background=dark
|
||||
" We need to apply this here too to make sure the startup components work
|
||||
colorscheme gruvbox
|
||||
|
||||
" Miscellaneous boilerplate
|
||||
set nocompatible " Disable vi compatibility
|
||||
set ignorecase
|
||||
set cc=128 " 128 characters
|
||||
set noswapfile
|
||||
set backupdir=~/.cache/nvim
|
||||
set cursorline " Highlight current line
|
||||
set mouse=a " Mouse
|
||||
set nofixendofline
|
||||
set clipboard+=unnamedplus " System clipboard
|
||||
|
||||
" Default indentation
|
||||
set softtabstop=4
|
||||
set tabstop=4
|
||||
set shiftwidth=4
|
||||
set expandtab
|
||||
set autoindent
|
||||
|
||||
" Syntax highlighting
|
||||
set syntax=on
|
||||
|
||||
let g:special_filetype_pattern = 'neo-tree\|toggleterm\|minimap'
|
||||
|
||||
" Show line numbers on non-toolbar buffers
|
||||
fun! ShowNumberIfNecessary()
|
||||
if &ft =~ g:special_filetype_pattern
|
||||
return
|
||||
endif
|
||||
setlocal nu
|
||||
endfun
|
||||
autocmd BufEnter * call ShowNumberIfNecessary()
|
||||
|
||||
" Terminal remapping
|
||||
lua << EOF
|
||||
function _G.set_terminal_keymaps()
|
||||
local opts = {buffer = 0}
|
||||
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
|
||||
end
|
||||
EOF
|
||||
autocmd TermOpen term://* lua set_terminal_keymaps()
|
128
nvim/.config/nvim/lua/plugins.lua
Normal file
128
nvim/.config/nvim/lua/plugins.lua
Normal file
|
@ -0,0 +1,128 @@
|
|||
vim.cmd [[packadd packer.nvim]]
|
||||
|
||||
return require('packer').startup(function(use)
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
-- LSP stuff
|
||||
use {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
}
|
||||
|
||||
-- Gruvbox theme
|
||||
use {
|
||||
"ellisonleao/gruvbox.nvim",
|
||||
config = function()
|
||||
require("gruvbox").setup({
|
||||
bold = false,
|
||||
italic = true,
|
||||
strikethrough = true,
|
||||
overrides = {
|
||||
Directory = { link = "GruvboxFg2" },
|
||||
},
|
||||
})
|
||||
vim.cmd("colorscheme gruvbox")
|
||||
end,
|
||||
}
|
||||
|
||||
-- A way saner buffer closing implementation
|
||||
use "ojroques/nvim-bufdel"
|
||||
|
||||
-- Indentation guide
|
||||
use "lukas-reineke/indent-blankline.nvim"
|
||||
|
||||
-- Indentation autodetection
|
||||
use {
|
||||
"nmac427/guess-indent.nvim",
|
||||
config = function()
|
||||
require("guess-indent").setup()
|
||||
end
|
||||
}
|
||||
|
||||
-- Scrollbar
|
||||
use {
|
||||
"petertriho/nvim-scrollbar",
|
||||
config = function()
|
||||
require("scrollbar").setup()
|
||||
end,
|
||||
}
|
||||
|
||||
-- Directory tree
|
||||
use {
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
branch = "v2.x",
|
||||
requires = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"kyazdani42/nvim-web-devicons",
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("neo-tree").setup({
|
||||
window = {
|
||||
position = "left",
|
||||
width = 36,
|
||||
},
|
||||
})
|
||||
require("neo-tree.sources.manager").show("filesystem")
|
||||
end,
|
||||
}
|
||||
|
||||
-- Tabs
|
||||
use {
|
||||
"akinsho/bufferline.nvim", tag = "v2.*", requires = "kyazdani42/nvim-web-devicons",
|
||||
config = function() require("bufferline").setup({
|
||||
options = {
|
||||
close_command = "BufDel %d",
|
||||
right_mouse_command = "BufDel %d",
|
||||
offsets = {
|
||||
{
|
||||
filetype = "neo-tree",
|
||||
text = "Files",
|
||||
highlight = "Directory",
|
||||
text_align = "left",
|
||||
}
|
||||
},
|
||||
separator_style = "slant",
|
||||
}
|
||||
}) end,
|
||||
}
|
||||
|
||||
-- Status line
|
||||
use {
|
||||
"nvim-lualine/lualine.nvim", requires = { 'kyazdani42/nvim-web-devicons', opt = true },
|
||||
config = function() require("lualine").setup({
|
||||
options = {
|
||||
theme = "gruvbox",
|
||||
disabled_filetypes = {
|
||||
statusline = { "neo-tree" },
|
||||
},
|
||||
},
|
||||
}) end,
|
||||
}
|
||||
|
||||
-- Terminal
|
||||
use {
|
||||
"akinsho/toggleterm.nvim", tag = "v2.*",
|
||||
config = function() require("toggleterm").setup({
|
||||
open_mapping = [[<c-\>]],
|
||||
persist_size = false,
|
||||
shade_terminals = false,
|
||||
hide_numbers = false,
|
||||
winbar = {
|
||||
enabled = false,
|
||||
},
|
||||
on_open = function()
|
||||
-- Toggle the neo-tree file view such that it is
|
||||
-- always full height; This is a dirty workaround
|
||||
local manager = require('neo-tree.sources.manager')
|
||||
if manager.close('filesystem') then
|
||||
manager.show('filesystem')
|
||||
end
|
||||
end,
|
||||
}) end,
|
||||
}
|
||||
end)
|
|
@ -6,3 +6,5 @@ set shiftwidth=4 softtabstop=4 expandtab
|
|||
|
||||
" In these files, use 2 spaces
|
||||
autocmd FileType sh setlocal shiftwidth=2 softtabstop=2
|
||||
|
||||
set nofixeol
|
||||
|
|
Loading…
Add table
Reference in a new issue