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
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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue