dotfiles

My dotfiles.
git clone git://git.ryanmj.xyz/dotfiles.git
Log | Files | Refs | LICENSE

commit 6b8b73247136b54607a8ec42f1b254ccfc56e9cc
parent abebffc0e7ea47fef43df172315a8a5ca93b8e77
Author: Ryan Jeffrey <ryan@ryanmj.xyz>
Date:   Sun, 14 Aug 2022 15:03:03 -0700

Working neovim c/c++ ide

Diffstat:
M.config/nvim/init.lua | 61++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
M.config/nvim/lua/plugins.lua | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
M.gitignore | 3+++
3 files changed, 117 insertions(+), 19 deletions(-)

diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua @@ -1,8 +1,11 @@ require('plugins') -local g = vim.g -local o = vim.o -local A = vim.api +local g = vim.g -- Global options. +local o = vim.o -- Vim options. +local A = vim.api -- Vim API. +local wo = vim.wo -- Window options. + +local absGrp = A.nvim_create_augroup("AbsoluteGroup", { clear = true }) -- Autocmd group -- Editor options. -- Do not save when switching buffers @@ -12,6 +15,12 @@ local A = vim.api o.timeoutlen = 500 o.updatetime = 200 +-- Show 80'th column. +vim.wo.colorcolumn = "80" + +-- TODO this in lua +vim.cmd 'hi ColorColumn ctermbg=gray guibg=gray' + -- Number of screen lines to keep above and below the cursor o.scrolloff = 8 o.number = true @@ -115,3 +124,49 @@ lsp.clangd.setup{ on_attach = on_attach, flags = lsp_flags, } + +-- YouCompleteMe +-- +g.ycm_language_server = {{ + name = 'c', + cmdline = {'/usr/bin/clangd'}, + filetypes = {'c'}, + project_root_files = {'Makefile', 'compile_commands.json'} +}} + +-- Clang-format + +-- Autostart. +A.nvim_create_autocmd("FileType", { + command = 'ClangFormatAutoEnable', + group = absGrp, + pattern = 'c,cpp,objc' +}) + + +-- Code formatting. + +-- If nvim version >= 0.7, use native lua functionality to handle autocmd. +-------------------------------------- Note: This does not work. --------------------------------- +if vim.fn.has "nvim-0.7" then + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = '.*', + callback = function() + vim.schedule(AbsCodeFormat) + end, + }) +else + vim.cmd "autocmd BufWritePre * lua AbsCodeFormat()" +end + +-- Function to format the code in the current buffer. +function AbsCodeFormat() + local bufnr = vim.api.nvim_get_current_buf() + local ft = vim.api.nvim_buf_get_option(bufnr, "filetype") + local fname = vim.fn.expand "%:p:t" + local keymap_c = {} + + -- if ft == 'c' or ft == 'cpp' or ft == 'objc' then + -- ClangFormat() + -- end +end diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua @@ -3,13 +3,16 @@ vim.cmd [[packadd packer.nvim]] return require('packer').startup(function(use) - use 'wbthomason/packer.nvim' -- The package manager. + use { + 'wbthomason/packer.nvim' -- The package manager. + --as = 'wbthomason.packer.nvim' + } use {'dracula/vim', as = 'dracula'} -- Dracula theme use { - -- Sakura theme. - 'numToStr/Sakura.nvim', + 'numToStr/Sakura.nvim', -- Sakura theme. + as = 'numToStr.Sakura.nvim', config = function() require('Sakura').load() end, @@ -17,8 +20,8 @@ return require('packer').startup(function(use) use({ { - -- Lualine modeline plugin. - 'nvim-lualine/lualine.nvim', + 'nvim-lualine/lualine.nvim', -- Lualine modeline plugin. + as = 'nvim-lualine.lualine.nvim', after = 'Sakura.nvim', event = 'BufEnter', config = function() @@ -26,8 +29,8 @@ return require('packer').startup(function(use) end, }, { - -- Lualine stuff. - 'j-hui/fidget.nvim', + 'j-hui/fidget.nvim', -- Lualine stuff. + as = 'j-hui.fidget.nvim', after = 'lualine.nvim', config = function() require('fidget').setup() @@ -35,23 +38,60 @@ return require('packer').startup(function(use) }, }) - use 'neovim/nvim-lspconfig' -- Configurations for Nvim LSP + use { + 'neovim/nvim-lspconfig', -- Configurations for Nvim LSP + as = 'neovim.nvim-lspconfig' + } - use 'https://github.com/tpope/vim-commentary' -- use gcc & gc to comment and uncomment code. + use { + 'https://github.com/tpope/vim-commentary', -- use gcc & gc to comment and uncomment code. + as = 'tpope.vim-commentary' + } - --use 'vim-airline/vim-airline' -- Arline plugin + use { + 'Raimondi/delimitMate', -- Delim matching. + as = 'Raimondi.delimitMate' + } + + use { + 'https://github.com/ryanoasis/vim-devicons', -- Developer icons. + as = 'ryanoasis.vim-devicons' + } + + use { + 'https://github.com/vim-python/python-syntax', -- Better python mode than nvim's default. + as = 'vim-python.python-syntax' + } - use 'Raimondi/delimitMate' -- Delim matching. + use { + 'https://github.com/Yggdroot/indentLine', -- Better python mode than nvim's default. + as = 'Yggdroot.indentLine' + } - use 'https://github.com/ryanoasis/vim-devicons' -- Developer icons. + use { + 'terryma/vim-multiple-cursors', -- Ctrl+N for multiple cursors + as = 'terryma.vim-multiple-cursors' + } - use 'https://github.com/vim-python/python-syntax' -- Better python mode than nvim's default. + use { + 'ntpeters/vim-better-whitespace', -- Show trailing whitespace. + as = 'ntpeters.vim-better-whitespace' + } - use 'https://github.com/Yggdroot/indentLine' -- Better python mode than nvim's default. + use { + 'ycm-core/YouCompleteMe', + as = 'ycm-core.YouCompleteMe' + } - use 'https://github.com/terryma/vim-multiple-cursors' -- Ctrl+N for multiple cursors + use { + 'rhysd/vim-clang-format', + as = 'rhysd.vim-clang-format' + } - use 'ntpeters/vim-better-whitespace' -- Show trailing whitespace. + use { + 'Shougo/vimproc.vim', + as = 'Shougo.vimproc.vim' + } end) diff --git a/.gitignore b/.gitignore @@ -102,6 +102,9 @@ flycheck_*.el !/.config/kitty !/.config/nvim !/.config/nvim/init.vim +!/.config/nvim/init.lua +!/.config/nvim/lua +!/.config/nvim/lua/plugins.lua !/.config/kitty/kitty.conf # Emacs !/.config/emacs/