rewrite nvim config to lua
Signed-off-by: Lucas Sta Maria <lucas.stamaria@gmail.com>
This commit is contained in:
parent
8e420fbf97
commit
c293767edf
9 changed files with 294 additions and 10 deletions
|
@ -1,11 +1,12 @@
|
||||||
.config/ambit/config.ambit;
|
.config/ambit/config.ambit;
|
||||||
.config/nvim/[
|
.config/nvim/[
|
||||||
init.vim,
|
init.lua,
|
||||||
startscreen.vimstart,
|
lua/[
|
||||||
UltiSnips/[
|
completion.lua,
|
||||||
cpp.snippets,
|
lsp.lua,
|
||||||
markdown.snippets,
|
mappings.lua,
|
||||||
tex.snippets
|
plugins.lua,
|
||||||
|
treesitter.lua
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
.config/eww/[
|
.config/eww/[
|
||||||
|
|
35
.config/nvim/init.lua
Normal file
35
.config/nvim/init.lua
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
-- https://github.com/priime0/dotfiles
|
||||||
|
|
||||||
|
-- given a key and value, set nvim's global settings of key to value
|
||||||
|
local function opt(key, value)
|
||||||
|
vim.o[key] = value
|
||||||
|
end
|
||||||
|
|
||||||
|
-- line numbers
|
||||||
|
opt("number", true)
|
||||||
|
opt("relativenumber", true)
|
||||||
|
|
||||||
|
-- tabs
|
||||||
|
opt("expandtab", true)
|
||||||
|
opt("tabstop", 4)
|
||||||
|
opt("shiftwidth", 4)
|
||||||
|
opt("smarttab", true)
|
||||||
|
|
||||||
|
-- indentation
|
||||||
|
opt("smartindent", true)
|
||||||
|
opt("autoindent", true)
|
||||||
|
|
||||||
|
-- misc
|
||||||
|
opt("termguicolors", true)
|
||||||
|
opt("scrolloff", 1)
|
||||||
|
opt("cursorline", true)
|
||||||
|
opt("showcmd", true)
|
||||||
|
opt("inccommand", "split")
|
||||||
|
opt("updatetime", 100)
|
||||||
|
opt("mouse", "a")
|
||||||
|
|
||||||
|
require("plugins")
|
||||||
|
require("mappings")
|
||||||
|
require("treesitter")
|
||||||
|
require("lsp")
|
||||||
|
require("completion")
|
|
@ -56,6 +56,7 @@ nnoremap <silent> <C-n>b :lua require"gitsigns".blame_line()<CR>
|
||||||
|
|
||||||
call plug#begin('~/.config/nvim/plugged')
|
call plug#begin('~/.config/nvim/plugged')
|
||||||
|
|
||||||
|
Plug 'wbthomason/packer.nvim'
|
||||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||||
Plug 'ayu-theme/ayu-vim'
|
Plug 'ayu-theme/ayu-vim'
|
||||||
Plug 'lewis6991/gitsigns.nvim', {'branch': 'main'}
|
Plug 'lewis6991/gitsigns.nvim', {'branch': 'main'}
|
||||||
|
@ -156,10 +157,6 @@ require'lspconfig'.ccls.setup{
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
lua << EOF
|
|
||||||
require'lspconfig'.pyls.setup{}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
lua << EOF
|
lua << EOF
|
||||||
require'lspconfig'.tsserver.setup{}
|
require'lspconfig'.tsserver.setup{}
|
||||||
EOF
|
EOF
|
||||||
|
|
31
.config/nvim/lua/completion.lua
Normal file
31
.config/nvim/lua/completion.lua
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
-- nvim-cmp
|
||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
completion = {
|
||||||
|
autocomplete = false
|
||||||
|
},
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require("luasnip").lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||||
|
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||||
|
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||||
|
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||||
|
['<C-e>'] = cmp.mapping({
|
||||||
|
i = cmp.mapping.abort(),
|
||||||
|
c = cmp.mapping.close(),
|
||||||
|
}),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
},
|
||||||
|
sources = cmp.config.sources {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "nvim_lua" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
{ name = "buffer" },
|
||||||
|
{ name = "path" }
|
||||||
|
}
|
||||||
|
}
|
70
.config/nvim/lua/lsp.lua
Normal file
70
.config/nvim/lua/lsp.lua
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
local lspconfig = require('lspconfig')
|
||||||
|
|
||||||
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
-- Enable completion
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc')
|
||||||
|
|
||||||
|
-- Mappings
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
|
||||||
|
lspconfig.ccls.setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
init_options = {
|
||||||
|
cache = {
|
||||||
|
directory = vim.fn.expand("$HOME/.cache/ccls/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lspconfig.rust_analyzer.setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
settings = {
|
||||||
|
["rust-analyzer"] = {
|
||||||
|
checkOnSave = {
|
||||||
|
command = "clippy"
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
disabled = {
|
||||||
|
"mismatched-arg-count"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lspconfig.tsserver.setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities
|
||||||
|
}
|
||||||
|
|
||||||
|
lspconfig.java_language_server.setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
cmd = { "/usr/share/java/java-language-server/lang_server_linux.sh" }
|
||||||
|
}
|
||||||
|
|
||||||
|
lspconfig.vuels.setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities
|
||||||
|
}
|
||||||
|
|
||||||
|
lspconfig.racket_langserver.setup {}
|
1
.config/nvim/lua/mappings.lua
Normal file
1
.config/nvim/lua/mappings.lua
Normal file
|
@ -0,0 +1 @@
|
||||||
|
vim.g.mapleader = "<Space>"
|
110
.config/nvim/lua/plugins.lua
Normal file
110
.config/nvim/lua/plugins.lua
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
local packer = require("packer")
|
||||||
|
local use = packer.use
|
||||||
|
|
||||||
|
packer.startup(function()
|
||||||
|
-- plugin/package manager
|
||||||
|
use("wbthomason/packer.nvim")
|
||||||
|
|
||||||
|
-- lib
|
||||||
|
use("nvim-lua/plenary.nvim")
|
||||||
|
|
||||||
|
-- language
|
||||||
|
use("nvim-treesitter/nvim-treesitter")
|
||||||
|
use("neovim/nvim-lspconfig")
|
||||||
|
use("j-hui/fidget.nvim")
|
||||||
|
|
||||||
|
-- ui
|
||||||
|
use("ayu-theme/ayu-vim")
|
||||||
|
use("nvim-lua/popup.nvim")
|
||||||
|
use("nvim-telescope/telescope.nvim")
|
||||||
|
use("lewis6991/gitsigns.nvim")
|
||||||
|
use("kyazdani42/nvim-web-devicons")
|
||||||
|
use("kyazdani42/nvim-tree.lua")
|
||||||
|
use("nvim-lualine/lualine.nvim")
|
||||||
|
use("akinsho/toggleterm.nvim")
|
||||||
|
|
||||||
|
-- completion
|
||||||
|
use("hrsh7th/nvim-cmp")
|
||||||
|
use("hrsh7th/cmp-path")
|
||||||
|
use("hrsh7th/cmp-buffer")
|
||||||
|
use("hrsh7th/cmp-nvim-lsp")
|
||||||
|
use("hrsh7th/cmp-nvim-lua")
|
||||||
|
use("L3MON4D3/LuaSnip")
|
||||||
|
use("saadparwaiz1/cmp_luasnip")
|
||||||
|
|
||||||
|
if packer_bootstrap then
|
||||||
|
require('packer').sync()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- fidget
|
||||||
|
require("fidget").setup {}
|
||||||
|
|
||||||
|
-- ayu
|
||||||
|
vim.cmd([[let ayucolor="dark"]])
|
||||||
|
vim.cmd([[colorscheme ayu]])
|
||||||
|
|
||||||
|
-- telescope
|
||||||
|
require("telescope").setup {
|
||||||
|
defaults = {
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
["<esc>"] = require("telescope.actions").close
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pickers = {
|
||||||
|
hidden = true,
|
||||||
|
file_ignore_patterns = { ".git/" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- git signs
|
||||||
|
require('gitsigns').setup {
|
||||||
|
signs = {
|
||||||
|
add = {hl = 'GitSignsAdd' , text = '│', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'},
|
||||||
|
change = {hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
|
||||||
|
delete = {hl = 'GitSignsDelete', text = '│', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
|
||||||
|
topdelete = {hl = 'GitSignsDelete', text = '│', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
|
||||||
|
changedelete = {hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
|
||||||
|
},
|
||||||
|
signcolumn = true,
|
||||||
|
numhl = false,
|
||||||
|
linehl = false,
|
||||||
|
word_diff = false,
|
||||||
|
watch_gitdir = {
|
||||||
|
interval = 1500,
|
||||||
|
follow_files = true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- nvim-web-devicons
|
||||||
|
require('nvim-web-devicons').setup {}
|
||||||
|
|
||||||
|
-- nvim-tree
|
||||||
|
require('nvim-tree').setup {
|
||||||
|
view = {
|
||||||
|
width = 25,
|
||||||
|
signcolumn = "no",
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
git = {
|
||||||
|
enable = true,
|
||||||
|
ignore = true,
|
||||||
|
timeout = 1500,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- lualine
|
||||||
|
require('lualine').setup {
|
||||||
|
options = {
|
||||||
|
theme = 'ayu_dark'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- toggleterm
|
||||||
|
require('toggleterm').setup {
|
||||||
|
open_mapping = [[<leader>ot]]
|
||||||
|
}
|
35
.config/nvim/lua/treesitter.lua
Normal file
35
.config/nvim/lua/treesitter.lua
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
local ts_config = require("nvim-treesitter.configs")
|
||||||
|
|
||||||
|
ts_config.setup {
|
||||||
|
ensure_installed = {
|
||||||
|
"bash",
|
||||||
|
"c",
|
||||||
|
"cpp",
|
||||||
|
"css",
|
||||||
|
"haskell",
|
||||||
|
"html",
|
||||||
|
"java",
|
||||||
|
"javascript",
|
||||||
|
"json",
|
||||||
|
"latex",
|
||||||
|
"lua",
|
||||||
|
"make",
|
||||||
|
"markdown",
|
||||||
|
"ocaml",
|
||||||
|
"python",
|
||||||
|
"regex",
|
||||||
|
"rust",
|
||||||
|
"scss",
|
||||||
|
"svelte",
|
||||||
|
"toml",
|
||||||
|
"tsx",
|
||||||
|
"typescript",
|
||||||
|
"vim",
|
||||||
|
"vue",
|
||||||
|
"yaml"
|
||||||
|
},
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
use_languagetree = true
|
||||||
|
}
|
||||||
|
}
|
|
@ -204,3 +204,7 @@ XF86AudioMute
|
||||||
|
|
||||||
super + {a,o}
|
super + {a,o}
|
||||||
pactl set-sink-volume @DEFAULT_SINK@ {+,-}2%
|
pactl set-sink-volume @DEFAULT_SINK@ {+,-}2%
|
||||||
|
|
||||||
|
# switch monitor mode
|
||||||
|
super + {x,b}
|
||||||
|
~/.screenlayout/{monitor,single-screen}.sh
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue