diff --git a/tycho/nvim/init.lua b/tycho/nvim/init.lua new file mode 100644 index 0000000..272d842 --- /dev/null +++ b/tycho/nvim/init.lua @@ -0,0 +1,45 @@ +require('plugins') + +-- comma as leader +vim.g.mapleader = "," + +-- load legacy options +vim.cmd([[ + so ~/.config/nvim/legacy.vim +]]) + +require('completion') +require('lsp-setup') + +-- nvim-treesitter +require('nvim-treesitter.configs').setup { + ensure_installed = { + "c", "lua", "vim", "help", "query", + "gitattributes", "gitcommit", "gitignore", + "json", "markdown", "yaml", "toml", + "make", "nix", "bash", + "php", "html", "css", + "python", "rust", + }, + highlight = { + enable = true, + }, +} + +-- lualine theme +require('lualine').setup { + options = { + theme = 'gruvbox', + -- no separators between lualine elements + section_separators = '', + component_separators = '' + } +} + +vim.opt.termguicolors = true +require("bufferline").setup{} + +-- settings for neovide +if vim.g.neovide then + vim.o.guifont = "Iosevka Term Medium:h12" +end diff --git a/tycho/nvim/init.vim b/tycho/nvim/legacy.vim similarity index 61% rename from tycho/nvim/init.vim rename to tycho/nvim/legacy.vim index efe656f..4b0e8c4 100644 --- a/tycho/nvim/init.vim +++ b/tycho/nvim/legacy.vim @@ -3,61 +3,61 @@ " syntax on " enable autocompletion of ale -let g:ale_completion_enabled = 1 +"let g:ale_completion_enabled = 1 " disable latex linting from ale as i've got my own plugin for that -let g:ale_linters = {'rust': ['analyzer'], 'tex': []} -let g:ale_fixers = {'c': ['clang-format']} +"let g:ale_linters = {'rust': ['analyzer'], 'tex': []} +"let g:ale_fixers = {'c': ['clang-format']} -" Initialize plugin system -call plug#begin(stdpath('data') . '/plugged') +"" Initialize plugin system +"call plug#begin(stdpath('data') . '/plugged') -" Make sure you use single quotes +"" Make sure you use single quotes -" Shorthand notation; fetches https://github.com/morhetz/gruvbox -" Plug 'morhetz/gruvbox' -Plug 'drewtempelmeyer/palenight.vim' +"" Shorthand notation; fetches https://github.com/morhetz/gruvbox +"" Plug 'morhetz/gruvbox' +"Plug 'drewtempelmeyer/palenight.vim' -" Any valid git URL is allowed -Plug 'https://github.com/scrooloose/nerdcommenter.git' +"" Any valid git URL is allowed +"Plug 'https://github.com/scrooloose/nerdcommenter.git' -" On-demand loading for languages -Plug 'rust-lang/rust.vim', { 'for': 'rust' } -Plug 'cespare/vim-toml', { 'for': 'toml' } -Plug 'keith/swift.vim', { 'for': 'swift' } -" Plug 'neovimhaskell/haskell-vim', { 'for': 'haskell' } +"" On-demand loading for languages +"Plug 'rust-lang/rust.vim', { 'for': 'rust' } +"Plug 'cespare/vim-toml', { 'for': 'toml' } +"Plug 'keith/swift.vim', { 'for': 'swift' } +"" Plug 'neovimhaskell/haskell-vim', { 'for': 'haskell' } -Plug 'vim-syntastic/syntastic' -Plug 'vim-airline/vim-airline' -Plug 'tpope/vim-fugitive' -Plug 'airblade/vim-gitgutter' -Plug 'justinmk/vim-sneak' -Plug 'lervag/vimtex' -Plug 'editorconfig/editorconfig-vim' -Plug 'LnL7/vim-nix' -Plug 'xevz/vim-squirrel' -Plug 'preservim/nerdtree' +"Plug 'vim-syntastic/syntastic' +"Plug 'vim-airline/vim-airline' +"Plug 'tpope/vim-fugitive' +"Plug 'airblade/vim-gitgutter' +"Plug 'justinmk/vim-sneak' +"Plug 'lervag/vimtex' +"Plug 'editorconfig/editorconfig-vim' +"Plug 'LnL7/vim-nix' +"Plug 'xevz/vim-squirrel' +"Plug 'preservim/nerdtree' -" Plugin outside ~/.vim/plugged with post-update hook -Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } -Plug 'junegunn/fzf.vim' +"" Plugin outside ~/.vim/plugged with post-update hook +"Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +"Plug 'junegunn/fzf.vim' -" ale language server client -Plug 'dense-analysis/ale' +"" ale language server client +"Plug 'dense-analysis/ale' -" Initialize plugin system -call plug#end() +"" Initialize plugin system +"call plug#end() " open fzf files in new tab instead of new buffer "command! -bang -nargs=? -complete=dir Files "\ call fzf#vim#files(, {'sink': 'tabedit', 'options': ['--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, 0) -set laststatus=2 -let g:airline#extensions#tabline#enabled = 1 +"set laststatus=2 +"let g:airline#extensions#tabline#enabled = 1 "let g:airline_powerline_fonts = 1 " window switching by # -let g:airline_section_c = '[%{winnr()}] %t' +"let g:airline_section_c = '[%{winnr()}] %t' nnoremap 1 1w nnoremap 2 2w nnoremap 3 3w @@ -74,9 +74,6 @@ nnoremap 0 10w set backspace=indent,eol,start -" map the leader key to , -let mapleader="," - let $FZF_DEFAULT_COMMAND = 'rg --files --hidden' " Cycling through windows and tabs @@ -110,8 +107,8 @@ set hidden " tex configuration let g:tex_flavor='latex' " Optics -colorscheme palenight "gruvbox -set background=dark " Setting dark mode +"colorscheme palenight "gruvbox +"set background=dark " Setting dark mode set number set relativenumber diff --git a/tycho/nvim/lua/completion.lua b/tycho/nvim/lua/completion.lua new file mode 100644 index 0000000..cc68f30 --- /dev/null +++ b/tycho/nvim/lua/completion.lua @@ -0,0 +1,67 @@ +-- Set up nvim-cmp. +local cmp = require'cmp' + +cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = cmp.mapping.confirm({ select = false }), -- Accept currently elected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, -- For vsnip users. + }, { + { name = 'buffer' }, + }) +}) + +-- Set configuration for specific filetype. +cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = 'buffer' }, + }) +}) + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) + +-- Set up lspconfig. +--local capabilities = require('cmp_nvim_lsp').default_capabilities() +-- Replace with each lsp server you've enabled. +--require('lspconfig')[''].setup { + --capabilities = capabilities +--} diff --git a/tycho/nvim/lua/lsp-setup.lua b/tycho/nvim/lua/lsp-setup.lua new file mode 100644 index 0000000..384e08f --- /dev/null +++ b/tycho/nvim/lua/lsp-setup.lua @@ -0,0 +1,71 @@ +-- Mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +local opts = { noremap=true, silent=true } +vim.api.nvim_set_keymap('n', ',e', 'lua vim.diagnostic.open_float()', opts) +vim.api.nvim_set_keymap('n', 'ge', 'lua vim.diagnostic.goto_prev()', opts) +vim.api.nvim_set_keymap('n', 'gE', 'lua vim.diagnostic.goto_next()', opts) +vim.api.nvim_set_keymap('n', ',q', 'lua vim.diagnostic.setloclist()', opts) + +-- 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) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + 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', 's', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'i', ',s', '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', ',rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', ',qf', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', ',F', 'lua vim.lsp.buf.format { async = true }', opts) +end + +-- Use a loop to conveniently call 'setup' on multiple servers and +-- map buffer local keybindings when the language server attaches +local servers = { 'clangd', 'rust_analyzer', 'nil_ls' } +for _, lsp in pairs(servers) do + require('lspconfig')[lsp].setup { + on_attach = on_attach, + flags = { + -- This will be the default in neovim 0.7+ + debounce_text_changes = 150, + } + } +end + +require('lspconfig').clangd.setup{ + on_attach = on_attach, + cmd = { + "clangd", + "--background-index", + "--pch-storage=memory", + "--clang-tidy", + "--suggest-missing-includes", + "--all-scopes-completion", + "--pretty", + "--header-insertion=never", + "-j=4", + "--inlay-hints", + "--header-insertion-decorators", + }, + filetypes = {"c", "cpp", "objc", "objcpp"}, + -- root_dir = utils.root_pattern("compile_commands.json", "compile_flags.txt", ".git") + init_option = { fallbackFlags = { "-std=c++2a" } } +} + +local capabilities = require('cmp_nvim_lsp').default_capabilities() + +require('lspconfig').pyright.setup { + on_attach = on_attach, + capabilities = capabilities +} diff --git a/tycho/nvim/lua/plugins.lua b/tycho/nvim/lua/plugins.lua new file mode 100644 index 0000000..f4521ec --- /dev/null +++ b/tycho/nvim/lua/plugins.lua @@ -0,0 +1,54 @@ +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + -- theme + -- use {'morhetz/gruvbox', config = function() vim.cmd.colorscheme("gruvbox") end } + use {'luisiacc/gruvbox-baby', config = function() vim.cmd.colorscheme("gruvbox-baby") end } + -- use 'drewtempelmeyer/palenight.vim' + use { + 'nvim-lualine/lualine.nvim', + requires = { 'nvim-tree/nvim-web-devicons', opt = true } + } + use {'akinsho/bufferline.nvim', tag = "*", requires = 'nvim-tree/nvim-web-devicons'} + + use 'scrooloose/nerdcommenter' + use 'sbdchd/neoformat' + + -- fuzzy file finder + use { 'junegunn/fzf', run = function() vim.fn['fzf#install'](0) end } + use 'junegunn/fzf.vim' + + -- -- On-demand loading for languages + use 'rust-lang/rust.vim' + -- use 'cespare/vim-toml + -- use 'keith/swift.vim' + -- use 'neovimhaskell/haskell-vim' + + -- Post-install/update hook with neovim command + use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } + + -- LSP plugins + use 'neovim/nvim-lspconfig' + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/cmp-path' + use 'hrsh7th/cmp-cmdline' + use 'hrsh7th/nvim-cmp' + -- snippet engine + use 'hrsh7th/vim-vsnip' + + use 'tpope/vim-fugitive' + -- use 'vim-syntastic/syntastic' + -- use 'vim-airline/vim-airline' + -- use 'airblade/vim-gitgutter' + -- use 'justinmk/vim-sneak' + -- use 'lervag/vimtex' + -- use 'editorconfig/editorconfig-vim' + -- use 'LnL7/vim-nix' + -- use 'xevz/vim-squirrel' + -- use 'preservim/nerdtree' + -- + -- -- ale language server client + -- use 'dense-analysis/ale' +end) diff --git a/tycho/terminal/alacritty.yml b/tycho/terminal/alacritty.yml index 32784ea..25226bb 100644 --- a/tycho/terminal/alacritty.yml +++ b/tycho/terminal/alacritty.yml @@ -105,7 +105,7 @@ font: # - (macOS) Menlo # - (Linux) monospace # - (Windows) Consolas - family: "Iosevka Term Medium" + family: "IosevkaTerm NFM Medium" #family: "Hack Nerd Font" #family: "Menlo" @@ -341,7 +341,8 @@ working_directory: None enable_experimental_conpty_backend: false # Send ESC (\x1b) before characters when alt is pressed. -alt_send_esc: true +#alt_send_esc: true +# window.option_as_alt is the new option for this! debug: # Display the time it takes to redraw each frame.