nvim: add org, completion, lsp
This commit is contained in:
parent
e1ab9ebdb0
commit
e2883114f1
|
@ -1,3 +1,6 @@
|
|||
require('plugins')
|
||||
require('settings')
|
||||
require('keymaps')
|
||||
require('fileformats')
|
||||
require('lsp')
|
||||
require('completion')
|
||||
|
|
70
.config/nvim/lua/completion.lua
Normal file
70
.config/nvim/lua/completion.lua
Normal file
|
@ -0,0 +1,70 @@
|
|||
require('plugins')
|
||||
|
||||
local cmp = require'cmp'
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
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 = false }),
|
||||
['<tab>'] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' }, -- For luasnip users.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'cmp_git' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline('/', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
-- setup lspconfig
|
||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
-- add for each enabled lsp server
|
||||
require('lspconfig')['clangd'].setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
||||
cmp.setup.filetype('lua', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lua' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
9
.config/nvim/lua/fileformats.lua
Normal file
9
.config/nvim/lua/fileformats.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
-- org
|
||||
require('orgmode').setup_ts_grammar()
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = {'org'}
|
||||
},
|
||||
ensure_installed = {'org'},
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
function map(mode, shortcut, command)
|
||||
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
|
||||
vim.keymap.set(mode, shortcut, command, { noremap = true, silent = true })
|
||||
end
|
||||
|
||||
map('n', '<M-Left>', ':tabprevious<cr>')
|
||||
|
|
44
.config/nvim/lua/lsp.lua
Normal file
44
.config/nvim/lua/lsp.lua
Normal file
|
@ -0,0 +1,44 @@
|
|||
require('plugins')
|
||||
require('keymaps')
|
||||
|
||||
map('n', '<f5>', vim.diagnostic.goto_prev)
|
||||
map('n', '<f6>', vim.diagnostic.goto_next)
|
||||
|
||||
-- Only map the following keys after the language server attaches to the
|
||||
-- current buffer
|
||||
-- TODO: get completion and key mappings to work.
|
||||
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')
|
||||
|
||||
local function maplsp(mode, shortcut, command)
|
||||
vim.keymap.set(mode, shortcut, command,
|
||||
{ noremap = true, silent = true, buffer=bufnr })
|
||||
end
|
||||
|
||||
maplsp('n', 'gD', vim.lsp.buf.declaration)
|
||||
maplsp('n', 'gd', vim.lsp.buf.definition)
|
||||
maplsp('n', 'K', vim.lsp.buf.hover)
|
||||
maplsp('n', 'gi', vim.lsp.buf.implementation)
|
||||
maplsp('n', '<C-k>', vim.lsp.buf.signature_help)
|
||||
maplsp('n', '<space>wa', vim.lsp.buf.add_workspace_folder)
|
||||
maplsp('n', '<space>wr', vim.lsp.buf.remove_workspace_folder)
|
||||
maplsp('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end)
|
||||
maplsp('n', '<space>D', vim.lsp.buf.type_definition)
|
||||
maplsp('n', '<space>rn', vim.lsp.buf.rename)
|
||||
maplsp('n', '<space>ca', vim.lsp.buf.code_action)
|
||||
maplsp('n', 'gr', vim.lsp.buf.references)
|
||||
maplsp('n', '<space>f', vim.lsp.buf.formatting)
|
||||
end
|
||||
|
||||
-- setup servers
|
||||
require'lspconfig'.clangd.setup{
|
||||
cmd = {
|
||||
'clangd',
|
||||
'--compile-commands-dir=build',
|
||||
'--clang-tidy', -- needs >=clangd-9
|
||||
'--ranking-model=decision_forest' -- needs >=clangd-12
|
||||
}
|
||||
}
|
|
@ -7,7 +7,32 @@ end
|
|||
|
||||
require('packer').startup(function(use)
|
||||
use 'https://github.com/wbthomason/packer.nvim'
|
||||
use 'https://github.com/GuiLra/vim'
|
||||
use 'https://github.com/owozsh/amora'
|
||||
-- file formats
|
||||
use {
|
||||
'https://github.com/nvim-orgmode/orgmode',
|
||||
config = function()
|
||||
require('orgmode').setup{}
|
||||
end
|
||||
}
|
||||
-- source code
|
||||
use 'https://github.com/tpope/vim-commentary'
|
||||
---- lsp
|
||||
use {
|
||||
'https://github.com/nvim-treesitter/nvim-treesitter',
|
||||
run = function()
|
||||
require('nvim-treesitter.install').update({ with_sync = true })
|
||||
end
|
||||
}
|
||||
use 'https://github.com/neovim/nvim-lspconfig'
|
||||
---- completion
|
||||
use 'https://github.com/L3MON4D3/LuaSnip'
|
||||
use 'https://github.com/hrsh7th/cmp-nvim-lsp'
|
||||
use 'https://github.com/hrsh7th/cmp-buffer'
|
||||
use 'https://github.com/hrsh7th/cmp-path'
|
||||
use 'https://github.com/hrsh7th/cmp-cmdline'
|
||||
use 'https://github.com/hrsh7th/cmp-nvim-lua'
|
||||
use 'https://github.com/hrsh7th/nvim-cmp'
|
||||
|
||||
if packer_bootstrap then
|
||||
require('packer').sync()
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
vim.o.number = true -- line numbers
|
||||
vim.o.list = true -- show whitespace
|
||||
vim.o.colorcolumn = '80,100' -- line length marker
|
||||
|
||||
vim.o.expandtab = true -- indent using spaces
|
||||
vim.o.tabstop = 4 -- 1 tab = 4 spaces
|
||||
vim.o.shiftwidth = 4 -- 1 indentation = 4 spaces
|
||||
|
||||
vim.o.completeopt = 'menu,menuone,noselect' -- completion popup
|
||||
|
||||
-- theme
|
||||
vim.o.termguicolors = true
|
||||
vim.o.termguicolors = true -- 24 bit colours
|
||||
vim.o.background = 'dark'
|
||||
vim.cmd('colorscheme omni')
|
||||
vim.cmd('colorscheme amora')
|
||||
|
|
Loading…
Reference in New Issue
Block a user