Skip to content

Instantly share code, notes, and snippets.

@Falconerd
Last active April 29, 2023 03:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Falconerd/7d2459122e73c94b2298179c0517ec05 to your computer and use it in GitHub Desktop.
Simple nvim setup Odin+C
vim.cmd([[
let mapleader = ' '
]])
require('packer').startup(function(use)
use "BurntSushi/ripgrep"
use "danilamihailov/beacon.nvim"
use "folke/todo-comments.nvim"
use "folke/trouble.nvim"
use "goolord/alpha-nvim"
use "hrsh7th/cmp-buffer"
use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-nvim-lsp-signature-help"
use "hrsh7th/cmp-nvim-lua"
use "hrsh7th/cmp-path"
use "hrsh7th/cmp-vsnip"
use "hrsh7th/nvim-cmp"
use "hrsh7th/vim-vsnip"
use "kyazdani42/nvim-tree.lua"
use "kyazdani42/nvim-web-devicons"
use "lewis6991/impatient.nvim"
use "lewis6991/gitsigns.nvim"
use "lukas-reineke/indent-blankline.nvim"
use "m-demare/hlargs.nvim"
use "mfussenegger/nvim-dap"
use "navarasu/onedark.nvim"
use "neovim/nvim-lspconfig"
use "numToStr/Comment.nvim"
use "nvim-lua/plenary.nvim"
use "nvim-lua/popup.nvim"
use "nvim-lualine/lualine.nvim"
use "nvim-telescope/telescope.nvim"
use "nvim-telescope/telescope-fzf-native.nvim"
use "nvim-treesitter/nvim-treesitter"
use "ggandor/leap.nvim"
use "preservim/tagbar"
use "puremourning/vimspector"
use "RRethy/vim-illuminate"
use "sharkdp/fd"
use "tpope/vim-surround"
use "voldikss/vim-floaterm"
use "wbthomason/packer.nvim"
use "williamboman/mason.nvim"
use "williamboman/mason-lspconfig.nvim"
use "windwp/nvim-autopairs"
use "ThePrimeagen/harpoon"
use "folke/tokyonight.nvim"
use "mbbill/undotree"
use "Tetralux/odin.vim"
use "JASONews/glow-hover"
use {
"folke/zen-mode.nvim",
config = function()
require("zen-mode").setup {
}
end
}
end)
require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
}
})
require("mason-lspconfig").setup()
require'lspconfig'.clangd.setup{}
-- LSP Diagnostics Options Setup
local sign = function(opts)
vim.fn.sign_define(opts.name, {
texthl = opts.name,
text = opts.text,
numhl = ''
})
end
sign({name = 'DiagnosticSignError', text = '!'})
sign({name = 'DiagnosticSignWarn', text = '~'})
sign({name = 'DiagnosticSignHint', text = '_'})
sign({name = 'DiagnosticSignInfo', text = '-'})
require("gitsigns").setup {
signcolumn = true,
}
vim.diagnostic.config({
virtual_text = false,
signs = true,
update_in_insert = true,
underline = true,
severity_sort = false,
float = {
border = 'rounded',
source = 'always',
header = '',
prefix = '',
},
})
vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'}
vim.opt.shortmess = vim.opt.shortmess + { c = true }
vim.api.nvim_set_option('updatetime', 300)
vim.cmd([[
set signcolumn=yes
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
]])
-- Completion Plugin Setup
local cmp = require'cmp'
cmp.setup({
-- Enable LSP snippets
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
-- Add tab support
['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<Tab>'] = cmp.mapping.select_next_item(),
['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
})
},
-- Installed sources:
sources = {
{ name = 'path' }, -- file paths
{ name = 'nvim_lsp', keyword_length = 3 }, -- from language server
{ name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized
{ name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.*
{ name = 'buffer', keyword_length = 2 }, -- source current buffer
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
{ name = 'calc'}, -- source for math calculation
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = {'menu', 'abbr', 'kind'},
format = function(entry, item)
local menu_icon ={
nvim_lsp = '╬╗',
vsnip = 'Γïù',
buffer = 'Ω',
path = '🖫',
}
item.menu = menu_icon[entry.source.name]
return item
end,
},
})
-- Treesitter Plugin Setup
require('nvim-treesitter.configs').setup {
ensure_installed = { "lua", "toml", "c" },
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting=false,
},
ident = { enable = true },
rainbow = {
enable = true,
extended_mode = true,
max_file_lines = nil,
}
}
-- Odin setup
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.odin = {
install_info = {
url = "https://github.com/ap29600/tree-sitter-odin",
branch = 'main',
files = {"src/parser.c"}
},
filetype = "odin"
}
-- Telescope
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>ff", builtin.find_files, {})
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
vim.keymap.set("n", "<leader>fh", builtin.oldfiles, {})
vim.keymap.set("n", "gd", vim.lsp.buf.definition, {})
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, {})
vim.keymap.set("n", "K", vim.lsp.buf.hover, {});
vim.keymap.set("n", "<c-k>", vim.lsp.buf.signature_help, {})
vim.keymap.set("n", "<leader>ft", ":FloatermNew --name=myfloat --height=0.8 --width=0.7 --autoclose=2 bash <cr> ")
require("leap").add_default_mappings()
vim.cmd([[colorscheme tokyonight]])
vim.keymap.set("n", "<C-j>", (function() require("harpoon.ui").toggle_quick_menu() end))
vim.keymap.set("n", "<C-h>", (function() require("harpoon.ui").nav_prev() end))
vim.keymap.set("n", "<C-k>", (function() require("harpoon.mark").add_file() end))
vim.keymap.set("n", "<C-l>", (function() require("harpoon.ui").nav_next() end))
vim.keymap.set("v", "K", ":m '<-2<cr>gv=gv")
vim.keymap.set("v", "J", ":m '>+1<cr>gv=gv")
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
vim.keymap.set("n", "<leader>br", '<cmd>!start cmd.exe @cmd /k ".\\build.bat && .\\dawnbreaker.exe"<cr>')
vim.keymap.set("n", "<leader>bb", "<cmd>!.\\build.bat<cr>")
-- after/ftplugin/odin.lua
if vim.fn.executable("ols") == 1 then
vim.lsp.start({
name = "ols",
cmd = { "ols", "--stdio" },
root_dir = vim.fs.dirname(vim.fs.find({".git"}, { upward = true })[1])
})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment