Browse Source

Moved Nvim to new configuration

master
Julio Biason 2 years ago
parent
commit
26f37f82e5
  1. 7
      nvim/after/plugin/colors.lua
  2. 42
      nvim/after/plugin/line.lua
  3. 32
      nvim/after/plugin/lsp.lua
  4. 5
      nvim/after/plugin/telescope.lua
  5. 35
      nvim/init.lua
  6. 3
      nvim/lua/mappings.lua
  7. 22
      nvim/lua/packager.lua
  8. 119
      nvim/lua/plugins.lua
  9. 13
      nvim/lua/set.lua
  10. 1
      nvim/pack/colors/start/molokai
  11. 1
      nvim/pack/colors/start/tokyonight-vim
  12. 1
      nvim/pack/plugins/start/nvim-autopairs
  13. 1
      nvim/pack/plugins/start/nvim-snippy
  14. 1
      nvim/pack/plugins/start/vim-commentary
  15. 1
      nvim/pack/syntaxes/start/vim-python-pep8-indent
  16. 16
      nvim/snippets/markdown.snippets
  17. 13
      nvim/snippets/rust.snippets

7
nvim/after/plugin/colors.lua

@ -0,0 +1,7 @@
vim.opt.background = "dark" -- the theme background is dark
vim.opt.termguicolors = true
vim.g.tokyonight_enable_italic = 1
vim.g.tokyonight_transparent = true
vim.g.tokyonight_style = "night"
vim.cmd("colorscheme tokyonight")

42
nvim/after/plugin/line.lua

@ -0,0 +1,42 @@
require("lualine").setup({
options = {
icons_enabled = true,
theme = 'ayu_mirage',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = {'mode'},
lualine_b = {'filename', 'branch'},
lualine_c = {
{
'diagnostics',
symbols = {error = 'Errors:', warn = 'Warns:', info = 'Info:', hint = 'Hints:'},
sources = { 'nvim_diagnostic' }
}
},
lualine_w = {'encoding'},
lualine_x = {'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {
lualine_a = {'tabs'},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {}
},
extensions = {}
})

32
nvim/after/plugin/lsp.lua

@ -0,0 +1,32 @@
local attachment = function(client, bufnr)
local opts = { noremap=true, silent=true }
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', 'gr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ga', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.format({async = true})<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ge', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gn', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
if client.resolved_capabilities.document_formatting then
vim.api.nvim_command [[augroup Format]]
vim.api.nvim_command [[autocmd! * <buffer>]]
vim.api.nvim_command [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
vim.api.nvim_command [[augroup END]]
end
end
local servers = { 'pyright', 'rust_analyzer', 'clangd' }
for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup {
on_attach = attachment
}
end

5
nvim/after/plugin/telescope.lua

@ -0,0 +1,5 @@
vim.api.nvim_set_keymap('n', '<leader><space>', '<cmd>Telescope find_files<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>p', '<cmd>Telescope git_files<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>g', '<cmd>Telescope live_grep<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>b', '<cmd>Telescope buffers<CR>', { noremap = true, silent = true })

35
nvim/init.lua

@ -1,32 +1,3 @@
require("set")
-- general configuration require("packager")
vim.opt.background = 'dark' -- the theme background is dark require("mappings")
vim.opt.termguicolors = true
vim.opt.cursorline = true -- highlight the line with the cursor
vim.opt.wrap = false -- do not wrap long lines
vim.opt.foldmethod = 'marker' -- when folding, use the marker
vim.opt.laststatus = 3 -- always show the status line, but only one, even with splits
vim.opt.showtabline = 2 -- always show the tab bar
vim.opt.scrolloff = 2 -- number of lines to always have around cursor
vim.opt.splitright = true -- vertical splits open on the right
vim.opt.splitbelow = true -- horizontal splits open on the bottom
vim.opt.number = true -- show line numbers
vim.opt.relativenumber = true -- line numbers are relative to the current line
vim.g.mapleader = ' ' -- space is the leader character
-- commands that don't exist in lua yet
vim.g.tokyonight_enable_italic = 1
-- vim.g.tokyonight_transparent_background = 1
-- vim.cmd [[
-- color tokyonight
-- ]]
-- Keybind: use '-' to open the file explorer
vim.api.nvim_set_keymap('n', '-', ':Ex<CR>', { noremap=true, silent=true })
-- Don't show signs on diagnostics
vim.diagnostic.config({signs = false})
-- My plugins and their configuration
require('plugins')

3
nvim/lua/mappings.lua

@ -0,0 +1,3 @@
-- Keybind: use '-' to open the file explorer
vim.api.nvim_set_keymap('n', '-', ':Ex<CR>', { noremap=true, silent=true })

22
nvim/lua/packager.lua

@ -0,0 +1,22 @@
return require("packer").startup(function(use)
use("wbthomason/packer.nvim")
use({"nvim-telescope/telescope.nvim",
requires = { { "nvim-lua/plenary.nvim" } },
})
use("neovim/nvim-lspconfig")
-- use("folke/tokyonight.nvim")
use("ghifarit53/tokyonight-vim")
use("nvim-treesitter/nvim-treesitter", {
run = ":TSUpdate"
})
use("romgrk/nvim-treesitter-context")
use("nvim-lualine/lualine.nvim")
use("windwp/nvim-autopairs")
use("tpope/vim-commentary")
end)

119
nvim/lua/plugins.lua

@ -1,119 +0,0 @@
vim.cmd [[packadd packer.nvim]]
return require('packer').startup(function()
-- packer
use 'wbthomason/packer.vim'
-- lspconfig
use {
'neovim/nvim-lspconfig',
config = function()
local attachment = function(client, bufnr)
local opts = { noremap=true, silent=true }
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', 'gr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ga', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.format({async = true})<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ge', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gn', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
if client.resolved_capabilities.document_formatting then
vim.api.nvim_command [[augroup Format]]
vim.api.nvim_command [[autocmd! * <buffer>]]
vim.api.nvim_command [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
vim.api.nvim_command [[augroup END]]
end
end
local servers = { 'pyright', 'rust_analyzer', 'clangd' }
for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup {
on_attach = attachment
}
end
end,
}
-- treesitter
use {
'nvim-treesitter/nvim-treesitter',
config = function()
require('nvim-treesitter.configs').setup {
ensure_installed = { "python", "rust" },
sync_install = false,
highlight = {
enable = true,
},
}
end,
}
-- status line
use {
'nvim-lualine/lualine.nvim',
config = function()
require('lualine').setup {
options = {
icons_enabled = true,
-- theme = 'ayu_dark',
theme = 'ayu_mirage',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = {'mode'},
lualine_b = {'filename', 'branch'},
lualine_c = {
{
'diagnostics',
symbols = {error = 'Errors:', warn = 'Warns:', info = 'Info:', hint = 'Hints:'},
sources = { 'nvim_diagnostic' }
}
},
lualine_w = {'encoding'},
lualine_x = {'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {
lualine_a = {'tabs'},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {}
},
extensions = {}
}
end
}
use {
'nvim-telescope/telescope.nvim',
requires = { {'nvim-lua/plenary.nvim'} },
config = function()
vim.api.nvim_set_keymap('n', '<leader><space>', '<cmd>Telescope find_files<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>g', '<cmd>Telescope live_grep<CR>', { noremap = true, silent = true })
end,
}
use 'windwp/nvim-autopairs'
end)

13
nvim/lua/set.lua

@ -0,0 +1,13 @@
vim.opt.relativenumber = true
vim.opt.number = true
vim.opt.errorbells = false
vim.opt.cursorline = true -- highlight the line with the cursor
vim.opt.wrap = false -- do not wrap long lines
vim.opt.foldmethod = 'marker' -- when folding, use the marker
vim.opt.laststatus = 3 -- always show the status line, but only one, even with splits
vim.opt.showtabline = 2 -- always show the tab bar
vim.opt.scrolloff = 2 -- number of lines to always have around cursor
vim.opt.splitright = true -- vertical splits open on the right
vim.opt.splitbelow = true -- horizontal splits open on the bottom
vim.g.mapleader = ' ' -- space is the leader character

1
nvim/pack/colors/start/molokai

@ -1 +0,0 @@
Subproject commit c67bdfcdb31415aa0ade7f8c003261700a885476

1
nvim/pack/colors/start/tokyonight-vim

@ -1 +0,0 @@
Subproject commit 4e82e0f0452a6ce8f387828ec71013015515035a

1
nvim/pack/plugins/start/nvim-autopairs

@ -1 +0,0 @@
Subproject commit 6617498bea01c9c628406d7e23030da57f2f8718

1
nvim/pack/plugins/start/nvim-snippy

@ -1 +0,0 @@
Subproject commit 81239281a758c42b8255be53a424359985013752

1
nvim/pack/plugins/start/vim-commentary

@ -1 +0,0 @@
Subproject commit 627308e30639be3e2d5402808ce18690557e8292

1
nvim/pack/syntaxes/start/vim-python-pep8-indent

@ -1 +0,0 @@
Subproject commit 60ba5e11a61618c0344e2db190210145083c91f8

16
nvim/snippets/markdown.snippets

@ -1,16 +0,0 @@
snippet header
+++
title = "$1"
date = `strftime('%Y-%m-%d')`
[taxonomies]
tags = ["$2"]
[extra.changelog]
`strftime('%Y-%m-%d')` = "Initial version"
+++
$0
snippet date
`strftime('%Y-%m-%d')`

13
nvim/snippets/rust.snippets

@ -1,13 +0,0 @@
snippet match
match ${1:condition} {
${2:arm} => $0
}
snippet envinit
env_logger::init();$0
snippet VERSION
const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");$0
snippet start
log::info!("Starting up ${1:name} v{}...", VERSION.unwrap_or("???"));$0
Loading…
Cancel
Save