First working setup in order to superseede Emacs
This commit is contained in:
14
init.lua
Normal file
14
init.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
if vim.g.neovide then
|
||||
-- Put anything you want to happen only in Neovide here
|
||||
vim.print(vim.g.neovide_version)
|
||||
vim.g.neovide_cursor_animation_length = 0
|
||||
vim.g.neovide_scroll_animation_length = 0
|
||||
end
|
||||
|
||||
vim.o.guifont = "Source Code Pro:h14" -- text below applies for VimScript
|
||||
|
||||
require('options')
|
||||
require('plugins')
|
||||
require('colorscheme')
|
||||
require('lsp')
|
||||
require('keybindings')
|
||||
21
lazy-lock.json
Normal file
21
lazy-lock.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
||||
"fzf-lua": { "branch": "main", "commit": "f39de2d77755e90a7a80989b007f0bf2ca13b0dd" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" },
|
||||
"lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" },
|
||||
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
|
||||
"neogit": { "branch": "master", "commit": "9bc4ee89bb42be31a2f0b1da41e36e3e6cab9bbb" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "0ef64599b8aa0187ee5f6d92cb39c951f348f041" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "9793801f974bba70e4ac5d7eae6c4f5659993d8e" },
|
||||
"orgmode": { "branch": "master", "commit": "e3500add486b17da58ce8e42a0f799161e5761c9" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" },
|
||||
"space-vim-theme": { "branch": "master", "commit": "4790dbba31f678f75af4f4c7a1465008542bd979" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" }
|
||||
}
|
||||
8
lua/colorscheme.lua
Normal file
8
lua/colorscheme.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
-- define your colorscheme here
|
||||
local colorscheme = 'lunaperche'
|
||||
|
||||
local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
|
||||
if not is_ok then
|
||||
vim.notify('colorscheme ' .. colorscheme .. ' not found!')
|
||||
return
|
||||
end
|
||||
79
lua/config/nvim-cmp.lua
Normal file
79
lua/config/nvim-cmp.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
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 luasnip = require("luasnip")
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
-- Use <C-b/f> to scroll the docs
|
||||
['<C-b>'] = cmp.mapping.scroll_docs( -4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
-- Use <C-k/j> to switch in items
|
||||
['<C-k>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-j>'] = cmp.mapping.select_next_item(),
|
||||
-- Use <CR>(Enter) to confirm selection
|
||||
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
|
||||
-- A super tab
|
||||
-- sourc: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
-- Hint: if the completion menu is visible select next one
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }), -- i - insert mode; s - select mode
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable( -1) then
|
||||
luasnip.jump( -1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
|
||||
-- Let's configure the item's appearance
|
||||
-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance
|
||||
formatting = {
|
||||
-- Set order from left to right
|
||||
-- kind: single letter indicating the type of completion
|
||||
-- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word"
|
||||
-- menu: extra text for the popup menu, displayed after "word" or "abbr"
|
||||
fields = { 'abbr', 'menu' },
|
||||
|
||||
-- customize the appearance of the completion menu
|
||||
format = function(entry, vim_item)
|
||||
vim_item.menu = ({
|
||||
nvim_lsp = '[Lsp]',
|
||||
luasnip = '[Luasnip]',
|
||||
buffer = '[File]',
|
||||
path = '[Path]',
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
|
||||
-- Set source precedence
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
||||
{ name = 'luasnip' }, -- For luasnip user
|
||||
{ name = 'buffer' }, -- For buffer word completion
|
||||
{ name = 'path' }, -- For path completion
|
||||
})
|
||||
})
|
||||
18
lua/keybindings.lua
Normal file
18
lua/keybindings.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
-- vim.keymap.set('i', 'todo', '<Tab>// TODO.<C-R>=strftime("%Y-%m-%d")<CR> ')
|
||||
|
||||
-- some shortcuts for LSP stuff
|
||||
vim.keymap.set('n', '<leader>l', ':lua vim.lsp.buf.code_action()<CR>')
|
||||
vim.keymap.set('n', '<leader>F', ':lua vim.lsp.buf.format()<CR>')
|
||||
|
||||
|
||||
-- Setup fzf-lua keybindings
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<leader>ff', fzf.files, {})
|
||||
vim.keymap.set('n', '<leader>fs', fzf.lines, {})
|
||||
vim.keymap.set('n', '<leader>fg', fzf.live_grep, {})
|
||||
vim.keymap.set('n', '<leader>fk', fzf.keymaps, {})
|
||||
vim.keymap.set('n', '<leader>fb', fzf.buffers, {})
|
||||
vim.keymap.set('n', '<leader>fc', fzf.commands, {})
|
||||
vim.keymap.set('n', '<leader>fC', fzf.command_history, {})
|
||||
vim.keymap.set('n', '<leader>fm', fzf.manpages, {})
|
||||
|
||||
91
lua/lsp.lua
Normal file
91
lua/lsp.lua
Normal file
@@ -0,0 +1,91 @@
|
||||
require('mason').setup({
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
require('mason-lspconfig').setup({
|
||||
-- A list of servers to automatically install if they're not already installed
|
||||
ensure_installed = {
|
||||
'pylsp',
|
||||
'lua_ls',
|
||||
'rust_analyzer',
|
||||
'yamlls',
|
||||
'tsserver',
|
||||
'gopls',
|
||||
'vuels'
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
-- Set different settings for different languages' LSP
|
||||
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
|
||||
-- - the settings table is sent to the LSP
|
||||
-- - on_attach: a lua callback function to run after LSP attaches to a given buffer
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
-- Customized on_attach function
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
vim.keymap.set('n', '<space>q', 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 <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, bufopts)
|
||||
end
|
||||
|
||||
-- Configure each language
|
||||
-- How to add LSP for a specific language?
|
||||
-- 1. use `:Mason` to install corresponding LSP
|
||||
-- 2. add configuration below
|
||||
lspconfig.pylsp.setup({
|
||||
on_attach = on_attach,
|
||||
})
|
||||
lspconfig.vuels.setup({
|
||||
on_attach = on_attach
|
||||
})
|
||||
lspconfig.rust_analyzer.setup({
|
||||
on_attach = on_attach
|
||||
})
|
||||
lspconfig.lua_ls.setup({
|
||||
on_attach = on_attach
|
||||
})
|
||||
lspconfig.yamlls.setup({
|
||||
on_attach = on_attach
|
||||
})
|
||||
lspconfig.tsserver.setup({
|
||||
on_attach = on_attach
|
||||
})
|
||||
lspconfig.gopls.setup({
|
||||
on_attach = on_attach
|
||||
})
|
||||
25
lua/options.lua
Normal file
25
lua/options.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
-- Hint: use `:h <option>` to figure out the meaning if needed
|
||||
vim.opt.clipboard = 'unnamedplus' -- use system clipboard
|
||||
vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
|
||||
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
|
||||
|
||||
-- Tab
|
||||
vim.opt.tabstop = 4 -- number of visual spaces per TAB
|
||||
vim.opt.softtabstop = 4 -- number of spacesin tab when editing
|
||||
vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab
|
||||
vim.opt.expandtab = true -- tabs are spaces, mainly because of python
|
||||
|
||||
-- UI config
|
||||
vim.opt.number = true -- show absolute number
|
||||
vim.opt.relativenumber = false -- add numbers to each line on the left side
|
||||
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
|
||||
vim.opt.splitbelow = true -- open new vertical split bottom
|
||||
vim.opt.splitright = true -- open new horizontal splits right
|
||||
-- vim.opt.termguicolors = true -- enabl 24-bit RGB color in the TUI
|
||||
vim.opt.showmode = false -- we are experienced, wo don't need the "-- INSERT --" mode hint
|
||||
|
||||
-- Searching
|
||||
vim.opt.incsearch = true -- search as characters are entered
|
||||
vim.opt.hlsearch = false -- do not highlight matches
|
||||
vim.opt.ignorecase = true -- ignore case in searches by default
|
||||
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
|
||||
112
lua/plugins.lua
Normal file
112
lua/plugins.lua
Normal file
@@ -0,0 +1,112 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", -- latest stable release
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
-- Vscode-like pictograms
|
||||
{
|
||||
"onsails/lspkind.nvim",
|
||||
event = { "VimEnter" },
|
||||
},
|
||||
|
||||
-- Auto-completion engine
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"lspkind.nvim",
|
||||
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
|
||||
"hrsh7th/cmp-buffer", -- buffer auto-completion
|
||||
"hrsh7th/cmp-path", -- path auto-completion
|
||||
"hrsh7th/cmp-cmdline", -- cmdline auto-completion
|
||||
},
|
||||
config = function()
|
||||
require("config.nvim-cmp")
|
||||
end,
|
||||
},
|
||||
|
||||
-- Code snippet engine
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
version = "v2.*",
|
||||
},
|
||||
|
||||
-- LSP manager
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
|
||||
-- neogit setup
|
||||
{
|
||||
"NeogitOrg/neogit",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim", -- required
|
||||
"sindrets/diffview.nvim", -- optional - Diff integration
|
||||
|
||||
-- Only one of these is needed, not both.
|
||||
-- "nvim-telescope/telescope.nvim", -- optional
|
||||
"ibhagwan/fzf-lua", -- optional
|
||||
},
|
||||
config = true
|
||||
},
|
||||
|
||||
-- org-mode
|
||||
{
|
||||
'nvim-orgmode/orgmode',
|
||||
event = 'VeryLazy',
|
||||
ft = { 'org' },
|
||||
config = function()
|
||||
-- Setup orgmode
|
||||
require('orgmode').setup({
|
||||
org_agenda_files = '~/orgfiles/**/*',
|
||||
org_default_notes_file = '~/orgfiles/refile.org',
|
||||
})
|
||||
|
||||
-- NOTE: If you are using nvim-treesitter with ~ensure_installed = "all"~ option
|
||||
-- add ~org~ to ignore_install
|
||||
-- require('nvim-treesitter.configs').setup({
|
||||
-- ensure_installed = 'all',
|
||||
-- ignore_install = { 'org' },
|
||||
-- })
|
||||
end,
|
||||
},
|
||||
|
||||
-- fzf-lua
|
||||
{
|
||||
"ibhagwan/fzf-lua",
|
||||
-- optional for icon support
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
-- calling `setup` is optional for customization
|
||||
require("fzf-lua").setup({})
|
||||
end
|
||||
},
|
||||
|
||||
-- whichkey
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the configuration section below
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
"<leader>?",
|
||||
function()
|
||||
require("which-key").show({ global = false })
|
||||
end,
|
||||
desc = "Buffer Local Keymaps (which-key)",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user