summaryrefslogtreecommitdiffstats
path: root/config/nvim
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2024-04-29 17:07:29 -0400
committerJon Santmyer <jon@jonsantmyer.com>2024-04-29 17:07:29 -0400
commitb4ffcbe13301291e0d04169a9ac0377d52621c4f (patch)
treed1c52818a26843747b74cb8d16c399e983e934b1 /config/nvim
parent69857d405fcc45194b4a4c4bb1f9946c05e50631 (diff)
parent7e1c5f4418a629d6f3bae954dd172ca81e476b3e (diff)
downloadnix-config-b4ffcbe13301291e0d04169a9ac0377d52621c4f.tar.gz
nix-config-b4ffcbe13301291e0d04169a9ac0377d52621c4f.tar.bz2
nix-config-b4ffcbe13301291e0d04169a9ac0377d52621c4f.zip
Merge remote-tracking branch 'origin/master' into desktop
Diffstat (limited to 'config/nvim')
-rw-r--r--config/nvim/init.lua14
-rw-r--r--config/nvim/init.vim71
-rw-r--r--config/nvim/lua/lsp.lua145
-rw-r--r--config/nvim/lua/settings.lua34
-rw-r--r--config/nvim/plugins.lua57
5 files changed, 179 insertions, 142 deletions
diff --git a/config/nvim/init.lua b/config/nvim/init.lua
deleted file mode 100644
index 4a80830..0000000
--- a/config/nvim/init.lua
+++ /dev/null
@@ -1,14 +0,0 @@
-local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
-if not vim.loop.fs_stat(lazypath) then
- vim.fn.system({
- "git",
- "clone",
- "--filter=blob:none",
- "https://github.com/folke/lazy.nvim.git",
- "--branch=stable",
- lazypath
- })
-end
-vim.opt.rtp:prepend(lazypath)
-
-require("lazy").setup("plugins")
diff --git a/config/nvim/init.vim b/config/nvim/init.vim
deleted file mode 100644
index 993ea88..0000000
--- a/config/nvim/init.vim
+++ /dev/null
@@ -1,71 +0,0 @@
-set termguicolors
-
-filetype plugin indent on
-set tabstop=4 softtabstop=4 shiftwidth=4
-set expandtab smarttab
-set autoindent
-set incsearch ignorecase smartcase hlsearch
-set encoding=utf-8
-set textwidth=0
-set number
-
-set hidden
-set title
-set noshowmode
-set noruler
-set noshowcmd
-
-set nobackup
-set nowritebackup
-
-set updatetime=300
-set signcolumn=yes
-
-let mapleader = "\<Space>"
-
-" Tab-trigger completion
-inoremap <silent><expr> <Tab>
- \ coc#pum#visible() ? coc#pum#next(1) :
- \ CheckBackspace() ? "\<Tab>" :
- \ coc#refresh()
-inoremap <expr><S-Tab> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
-
-inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() :
- \ "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
-
-function! CheckBackspace() abort
- let col = col('.') - 1
- return !col || getline('.')[col - 1] =~# '\s'
-endfunction
-
-inoremap <silent><expr> <c-space> coc#refresh()
-
-nmap <silent> [g <Plug>(coc-diagnostic-prev)
-nmap <silent> ]g <Plug>(coc-diagnostic-next)
-
-nmap <silent> gd <Plug>(coc-definition)
-nmap <silent> gy <Plug>(coc-type-definition)
-nmap <silent> gi <Plug>(coc-implementation)
-nmap <silent> gr <Plug>(coc-references)
-
-nnoremap <silent> K :call ShowDocumentation()<CR>
-
-function! ShowDocumentation()
- if CocAction('hasProvider', 'hover')
- call CocActionAsync('doHover')
- else
- call feedkeys('K', 'in')
- endif
-endfunction
-
-autocmd CursorHold * silent call CocActionAsync('highlight')
-
-" Telescope
-nnoremap <leader>ff <cmd>Telescope find_files<cr>
-nnoremap <leader>fg <cmd>Telescope live_grep<cr>
-nnoremap <leader>fb <cmd>Telescope buffers<cr>
-nnoremap <leader>fh help_tags<cr>
-
-lua require('init')
-
-color catppuccin
diff --git a/config/nvim/lua/lsp.lua b/config/nvim/lua/lsp.lua
new file mode 100644
index 0000000..1056431
--- /dev/null
+++ b/config/nvim/lua/lsp.lua
@@ -0,0 +1,145 @@
+local cmp = require("cmp")
+local nvim_lsp = require("lspconfig")
+local cmp_window = require("cmp.utils.window")
+
+vim.o.completeopt = "menuone,noselect"
+vim.o.shortmess = vim.o.shortmess .. "c"
+
+local function on_attach(client, bufn)
+ local function map(...)
+ vim.api.nvim_buf_set_keymap(bufn, ...)
+ end
+
+ local function buf_set_option(...)
+ vim.api.nvim_buf_set_option(bufn, ...)
+ end
+
+ local opts = { noremap = true, silent = true }
+ map("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
+ map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
+ map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
+ map("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>", opts)
+ map("n", "<C-k>", "<Cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
+ map("n", "<leader>D", "<Cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
+ map("n", "gr", "<Cmd>lua vim.lsp.buf.references()<CR>", opts)
+ map("n", "<leader>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
+ map("n", "[d", "<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
+ map("n", "]d", "<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
+ map("n", "<leader>q", "<Cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
+ map("n", "ga", "<Cmd>lua vim.lsp.buf.code_action()<CR>", opts)
+end
+
+local function has_words_before()
+ local line, col = unpack(vim.api.nvim_win_get_cursor(0))
+ return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
+end
+
+local function feedkey(key, mode)
+ vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
+end
+
+local function border(hl_name)
+ return {
+ { "╭", hl_name },
+ { "─", hl_name },
+ { "╮", hl_name },
+ { "│", hl_name },
+ { "╯", hl_name },
+ { "─", hl_name },
+ { "╰", hl_name },
+ { "│", hl_name },
+ }
+end
+
+cmp_window.info_ = cmp_window.info
+cmp_window.info = function(self)
+ local info = self:info_()
+ info.scrollable = false
+ return info
+end
+
+cmp.setup({
+ window = {
+ completion = {
+ border = border "CmpBorder",
+ winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
+ },
+ documentation = {
+ border = border "CmpDocBorder"
+ },
+ },
+ snippet = {
+ expand = function(args)
+ vim.fn["vsnip#anonymous"](args.body)
+ end,
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.abort(),
+ ['<CR>'] = cmp.mapping.confirm({select = true}),
+ ["<Tab>"] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ elseif vim.fn["vsnip#available"](1) == 1 then
+ feedkey("<Plug>(vsnip-expand-or-jump)", "")
+ elseif has_words_before() then
+ cmp.complete()
+ else
+ fallback()
+ end
+ end, {"i", "s"}),
+
+ ["<S-Tab"] = cmp.mapping(function()
+ if cmp.visible() then
+ cmp.select_prev_item()
+ elseif vim.fn["vsnip#jumpable"](-1) == 1 then
+ feedkey("<Plug>(vsnip-jump-prev)", "")
+ end
+ end, {"i", "s"}),
+ }),
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ { name = "vsnip" },
+ { name = "treesitter" },
+ { name = "path", option = { trailing_slash = true }},
+ { name = "buffer" }
+ }),
+})
+
+cmp.setup.cmdline(":", {
+ mapping = cmp.mapping.preset.cmdline(),
+ sources = cmp.config.sources({
+ { name = "path" },
+ }, {
+ { name = "cmdline" },
+ }),
+})
+
+vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
+ vim.lsp.diagnostic.on_publish_diagnostics, {
+ virtual_text = true,
+ signs = true,
+ update_in_insert = true
+ }
+)
+
+local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
+
+local servers = { "ccls", "bashls", "rnix", "texlab", "lua_ls" }
+
+for _, lang in pairs(servers) do
+ nvim_lsp[lang].setup({
+ root_dir = vim.loop.cwd,
+ on_attach = on_attach,
+ capabilities = capabilities
+ })
+end
+
+require("nvim-treesitter.configs").setup({
+ highlight = { enable = true, },
+})
+
+require("gitsigns").setup({})
+
diff --git a/config/nvim/lua/settings.lua b/config/nvim/lua/settings.lua
new file mode 100644
index 0000000..6f440bb
--- /dev/null
+++ b/config/nvim/lua/settings.lua
@@ -0,0 +1,34 @@
+vim.g.mapleader = " "
+
+vim.g.loaded_netrw = 1
+vim.g.loaded_netrwPlugin = 1
+
+--Decorative
+vim.opt.termguicolors = true
+vim.opt.cursorline = true
+vim.opt.number = true
+vim.opt.signcolumn = "yes"
+vim.opt.cmdheight = 1
+vim.cmd.colorscheme "catppuccin"
+
+--Undo
+vim.opt.undofile = true
+
+--Indents
+vim.opt.smartindent = true
+vim.opt.autoindent = true
+vim.opt.tabstop = 4
+vim.opt.shiftwidth = 4
+vim.opt.softtabstop = 4
+vim.opt.expandtab = true
+
+--Clipboard
+vim.opt.clipboard = "unnamedplus"
+
+--Misc
+vim.opt.hidden = true
+vim.opt.smartcase = true
+vim.opt.splitbelow = true
+vim.opt.splitright = true
+vim.opt.colorcolumn = "80"
+vim.opt.updatetime = 250
diff --git a/config/nvim/plugins.lua b/config/nvim/plugins.lua
deleted file mode 100644
index 83c74ad..0000000
--- a/config/nvim/plugins.lua
+++ /dev/null
@@ -1,57 +0,0 @@
-return
-{
- { "neovim/nvim-lspconfig" },
- { "MordechaiHadad/nvim-lspmanager",
- dependencies = { "neovim/nvim-lspconfig" },
- config = function()
- require('lspmanager').setup({
- ensure_installed = {
- "clangd"
- }
- })
- end
- },
- { "nvim-treesitter/nvim-treesitter",
- build = ":TSUpdate",
- config = function()
- require('nvim-treesitter.configs').setup{
- ensure_installed = { "c", "cpp" },
- auto_install = true,
- highlight = {
- enable = true
- }
- }
- end
- },
- { "neoclide/coc.nvim", branch="release" },
- { "nvim-lua/plenary.nvim" },
- { "nvim-telescope/telescope.nvim", tag = '0.1.3',
- dependencies = { 'nvim-lua/plenary.nvim' }
- },
- { "nvim-tree/nvim-web-devicons" },
- { "lewis6991/gitsigns.nvim",
- config = function()
- require('gitsigns').setup()
- end
- },
- { "tpope/vim-surround" },
- { "catppuccin/nvim", name="catppuccin", priority=1000 },
- { "feline-nvim/feline.nvim",
- config = function()
- local ctp_feline = require('catppuccin.groups.integrations.feline')
- require('feline').setup({
-
- })
- end
- },
- { "romgrk/barbar.nvim",
- dependencies = {
- 'lewis6991/gitsigns.nvim',
- 'nvim-tree/nvim-web-devicons'
- },
- init = function() vim.g.barbar_auto_setup = false end,
- config = function()
- require('barbar').setup()
- end
- }
-}