diff --git a/nvim/after/plugin/colors.lua b/nvim/after/plugin/colors.lua new file mode 100644 index 0000000..aa4f521 --- /dev/null +++ b/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") diff --git a/nvim/after/plugin/line.lua b/nvim/after/plugin/line.lua new file mode 100644 index 0000000..427200a --- /dev/null +++ b/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 = {} +}) diff --git a/nvim/after/plugin/lsp.lua b/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..0fdad39 --- /dev/null +++ b/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', 'lua vim.lsp.buf.declaration()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ga', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.format({async = true})', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ge', 'lua vim.diagnostic.open_float()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gn', 'lua vim.diagnostic.goto_next()', opts) + + if client.resolved_capabilities.document_formatting then + vim.api.nvim_command [[augroup Format]] + vim.api.nvim_command [[autocmd! * ]] + vim.api.nvim_command [[autocmd BufWritePre 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 + diff --git a/nvim/after/plugin/telescope.lua b/nvim/after/plugin/telescope.lua new file mode 100644 index 0000000..46df167 --- /dev/null +++ b/nvim/after/plugin/telescope.lua @@ -0,0 +1,5 @@ +vim.api.nvim_set_keymap('n', '', 'Telescope find_files', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'p', 'Telescope git_files', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'g', 'Telescope live_grep', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'b', 'Telescope buffers', { noremap = true, silent = true }) + diff --git a/nvim/init.lua b/nvim/init.lua index f4d56c5..f6d1af4 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,32 +1,3 @@ - --- general configuration -vim.opt.background = 'dark' -- the theme background is dark -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', { noremap=true, silent=true }) - --- Don't show signs on diagnostics -vim.diagnostic.config({signs = false}) - --- My plugins and their configuration -require('plugins') +require("set") +require("packager") +require("mappings") diff --git a/nvim/lua/mappings.lua b/nvim/lua/mappings.lua new file mode 100644 index 0000000..b5ac2ee --- /dev/null +++ b/nvim/lua/mappings.lua @@ -0,0 +1,3 @@ +-- Keybind: use '-' to open the file explorer +vim.api.nvim_set_keymap('n', '-', ':Ex', { noremap=true, silent=true }) + diff --git a/nvim/lua/packager.lua b/nvim/lua/packager.lua new file mode 100644 index 0000000..0078f11 --- /dev/null +++ b/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) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua deleted file mode 100644 index 8f21d2f..0000000 --- a/nvim/lua/plugins.lua +++ /dev/null @@ -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', 'lua vim.lsp.buf.declaration()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.rename()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ga', 'lua vim.lsp.buf.code_action()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'f', 'lua vim.lsp.buf.format({async = true})', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ge', 'lua vim.diagnostic.open_float()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gn', 'lua vim.diagnostic.goto_next()', opts) - - if client.resolved_capabilities.document_formatting then - vim.api.nvim_command [[augroup Format]] - vim.api.nvim_command [[autocmd! * ]] - vim.api.nvim_command [[autocmd BufWritePre 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', '', 'Telescope find_files', { noremap = true, silent = true }) - vim.api.nvim_set_keymap('n', 'g', 'Telescope live_grep', { noremap = true, silent = true }) - end, - } - - use 'windwp/nvim-autopairs' -end) diff --git a/nvim/lua/set.lua b/nvim/lua/set.lua new file mode 100644 index 0000000..3c25551 --- /dev/null +++ b/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 diff --git a/nvim/pack/colors/start/molokai b/nvim/pack/colors/start/molokai deleted file mode 160000 index c67bdfc..0000000 --- a/nvim/pack/colors/start/molokai +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c67bdfcdb31415aa0ade7f8c003261700a885476 diff --git a/nvim/pack/colors/start/tokyonight-vim b/nvim/pack/colors/start/tokyonight-vim deleted file mode 160000 index 4e82e0f..0000000 --- a/nvim/pack/colors/start/tokyonight-vim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4e82e0f0452a6ce8f387828ec71013015515035a diff --git a/nvim/pack/plugins/start/nvim-autopairs b/nvim/pack/plugins/start/nvim-autopairs deleted file mode 160000 index 6617498..0000000 --- a/nvim/pack/plugins/start/nvim-autopairs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6617498bea01c9c628406d7e23030da57f2f8718 diff --git a/nvim/pack/plugins/start/nvim-snippy b/nvim/pack/plugins/start/nvim-snippy deleted file mode 160000 index 8123928..0000000 --- a/nvim/pack/plugins/start/nvim-snippy +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 81239281a758c42b8255be53a424359985013752 diff --git a/nvim/pack/plugins/start/vim-commentary b/nvim/pack/plugins/start/vim-commentary deleted file mode 160000 index 627308e..0000000 --- a/nvim/pack/plugins/start/vim-commentary +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 627308e30639be3e2d5402808ce18690557e8292 diff --git a/nvim/pack/syntaxes/start/vim-python-pep8-indent b/nvim/pack/syntaxes/start/vim-python-pep8-indent deleted file mode 160000 index 60ba5e1..0000000 --- a/nvim/pack/syntaxes/start/vim-python-pep8-indent +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 60ba5e11a61618c0344e2db190210145083c91f8 diff --git a/nvim/snippets/markdown.snippets b/nvim/snippets/markdown.snippets deleted file mode 100644 index 01727ca..0000000 --- a/nvim/snippets/markdown.snippets +++ /dev/null @@ -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')` diff --git a/nvim/snippets/rust.snippets b/nvim/snippets/rust.snippets deleted file mode 100644 index a450815..0000000 --- a/nvim/snippets/rust.snippets +++ /dev/null @@ -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