Skip to content

Instantly share code, notes, and snippets.

@masonamccallum
Last active October 8, 2023 03:44
Show Gist options
  • Save masonamccallum/65c98ef803895eca11ac072f7d7de963 to your computer and use it in GitHub Desktop.
Save masonamccallum/65c98ef803895eca11ac072f7d7de963 to your computer and use it in GitHub Desktop.
minimal neovim config
--git clone https://gist.github.com/65c98ef803895eca11ac072f7d7de963.git ~/.config/nvim
--julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.add(LanguageServer)'
--https://github.com/fredrikekre/.dotfiles/blob/master/.julia/environments/nvim-lspconfig/Makefile
-- -----------------------------------------------
-- Basic Setting |
-- -----------------------------------------------
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.o.hlsearch = true
vim.wo.relativenumber = true
vim.o.mouse = 'a'
vim.o.clipboard = 'unnamedplus'
vim.o.breakindent = true
vim.o.undofile = true
vim.o.ignorecase = true
vim.o.smartcase = true
vim.wo.signcolumn = 'yes'
vim.o.updatetime = 250
vim.o.timeoutlen = 300
vim.opt.swapfile = false
vim.opt.spelllang = "en_gb"
vim.opt.cursorline = true
-- [[ Tab settings ]]
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.autoindent = true
-- [[ colors ]]
vim.o.termguicolors = true
-- Lua initialization file
-- [[ Basic Keymaps ]]
vim.keymap.set('i', 'jk', '<Esc>')
-- -----------------------------------------------
-- Custom functions |
-- -----------------------------------------------
-- [[ Highlight on yank ]]
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
pattern = '*',
})
-- ------------------------------------------------------------
-- Plugin manager |
-- ------------------------------------------------------------
-- local vim = vim
local execute = vim.api.nvim_command
local fn = vim.fn
-- ensure that packer is installed
local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
execute('!git clone https://github.com/wbthomason/packer.nvim '..install_path)
execute 'packadd packer.nvim'
end
vim.cmd('packadd packer.nvim')
local packer = require'packer'
local util = require'packer.util'
packer.init({
package_root = util.join_paths(vim.fn.stdpath('data'), 'site', 'pack')
})
--- startup and add configure plugins
-- add you plugins here like:
packer.startup(function()
use 'neovim/nvim-lspconfig'
use 'jpalardy/vim-slime'
use 'tpope/vim-fugitive'
use 'lervag/vimtex'
use 'airblade/vim-gitgutter'
use {
'renerocksai/telekasten.nvim',
requires = {'nvim-telescope/telescope.nvim'}
}
use {
'VonHeikemen/lsp-zero.nvim',
branch = 'v1.x',
requires = {
{'neovim/nvim-lspconfig'}, -- Required
{'williamboman/mason.nvim'}, -- Optional
{'williamboman/mason-lspconfig.nvim'}, -- Optional
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'hrsh7th/cmp-buffer'}, -- Optional
{'hrsh7th/cmp-path'}, -- Optional
{'saadparwaiz1/cmp_luasnip'}, -- Optional
{'hrsh7th/cmp-nvim-lua'}, -- Optional
{'L3MON4D3/LuaSnip'}, -- Required
{'rafamadriz/friendly-snippets'}, -- Optional
},
use {"akinsho/toggleterm.nvim", tag = '*' },
use "terrortylor/nvim-comment",
use "CreaturePhil/vim-handmade-hero"
}
use { "bluz71/vim-moonfly-colors", name = "moonfly", priority = 1000 }
use {
'nvim-telescope/telescope.nvim', tag = '0.1.3',
requires = {'nvim-lua/plenary.nvim'}
}
use('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'})
-- install without yarn or npm
use({
"iamcco/markdown-preview.nvim",
run = function() vim.fn["mkdp#util#install"]() end,
})
use({ "iamcco/markdown-preview.nvim", run = "cd app && npm install", setup = function() vim.g.mkdp_filetypes = { "markdown" } end, ft = { "markdown" }, })
end
)
-- ------------------------------------------------------------
-- LSP
-- ------------------------------------------------------------
-- LSP
local lsp = require("lsp-zero")
lsp.preset("recommended")
lsp.ensure_installed({
"tsserver",
"eslint",
"julials",
})
lsp.set_preferences({
sign_icons = {}
})
lsp.on_attach(function(client, bufnr)
local opts = {buffer = bufnr, remap = false}
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
end)
lsp.setup()
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
signs = false,
underline = false,
virtual_text = false,
}
)
-- ------------------------------------------------------------
-- Plugin config |
-- ------------------------------------------------------------
vim.cmd [[colorscheme moonfly]]
-- [[ telescope ]]
vim.keymap.set('n', '<leader>tf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>tg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>tb', require('telescope.builtin').buffers, { desc = '[t]elescope [B]uffers' })
-- TREESITTER
require'nvim-treesitter.configs'.setup {
ensure_installed = {"c", "lua", "vim", "python", "julia"},
highlight = {
enable = false,
}
}
-- [[ vim-slime config ]]
vim.g.slime_target = 'tmux'
vim.api.nvim_command [[let g:slime_default_config = {"socket_name":get(split($TMUX,","), 0), "target_pane":":.0"}]]
-- [[ telekasten ]]
require('telekasten').setup({
home = vim.fn.expand("~/zettelkasten"), -- Put the name of your notes directory here
})
-- Launch panel if nothing is typed after <leader>z
vim.keymap.set("n", "<leader>z", "<cmd>Telekasten panel<CR>")
-- Most used functions
vim.keymap.set("n", "<leader>zf", "<cmd>Telekasten find_notes<CR>")
vim.keymap.set("n", "<leader>zg", "<cmd>Telekasten search_notes<CR>")
vim.keymap.set("n", "<leader>zd", "<cmd>Telekasten goto_today<CR>")
vim.keymap.set("n", "<leader>zz", "<cmd>Telekasten follow_link<CR>")
vim.keymap.set("n", "<leader>zn", "<cmd>Telekasten new_note<CR>")
vim.keymap.set("n", "<leader>zc", "<cmd>Telekasten show_calendar<CR>")
vim.keymap.set("n", "<leader>zb", "<cmd>Telekasten show_backlinks<CR>")
vim.keymap.set("n", "<leader>zI", "<cmd>Telekasten insert_img_link<CR>")
-- Call insert link automatically when we start typing a link
vim.keymap.set("i", "[[", "<cmd>Telekasten insert_link<CR>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment