nvim: add fzf integration
Also, minor stylistic changes
This commit is contained in:
parent
ec65a6d30d
commit
16fc4e1848
3 changed files with 36 additions and 37 deletions
|
@ -1,7 +1,7 @@
|
|||
local map = vim.keymap.set
|
||||
local has_words_before = function()
|
||||
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
|
||||
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 lsp = require('lspconfig')
|
||||
|
@ -34,18 +34,13 @@ cmp.setup({
|
|||
{name = 'buffer', max_item_count = 10},
|
||||
{name = 'path', priority = 1}
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
-- LSP
|
||||
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')
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||
map('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
map('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
map('n', 'F', vim.lsp.buf.hover, bufopts)
|
||||
|
@ -54,12 +49,10 @@ local on_attach = function(client, bufnr)
|
|||
map('n', 'gS', vim.lsp.buf.signature_help, bufopts)
|
||||
map('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
map('n', '<space>cw', vim.lsp.buf.rename, bufopts)
|
||||
map('n', '<space>f', vim.lsp.buf.formatting, bufopts)
|
||||
end
|
||||
|
||||
-- GoLang
|
||||
lsp['gopls'].setup{
|
||||
cmd = {'gopls'},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
cmd = {'gopls'},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ local map = vim.keymap.set
|
|||
local opts = { noremap=true, silent=true }
|
||||
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.fzf_action = { enter = 'tab split', ['ctrl-t'] = 'vsplit' }
|
||||
|
||||
-- Windows
|
||||
map('n', '<C-h>', '<C-w>h')
|
||||
|
@ -22,6 +23,7 @@ map('n', '<C-p>', ':bnext<CR>')
|
|||
map('n', '<C-x>', ':bdelete<CR>')
|
||||
|
||||
-- Leader binds
|
||||
map('', '<leader>p', ':!opout <c-r>%<CR><CR>')
|
||||
map('', '<leader>c', ':w! | !compiler "<c-r>%"<CR>')
|
||||
map('', '<leader>f', ':FZF<CR>')
|
||||
map('', '<leader>p', ':!opout <c-r>%<CR><CR>')
|
||||
map('', '<leader>se', ':setlocal spell! spelllang=en_us<CR>')
|
||||
|
|
|
@ -1,35 +1,39 @@
|
|||
g = vim.g
|
||||
o = vim.o
|
||||
wo = vim.wo
|
||||
bo = vim.bo
|
||||
au = vim.api.nvim_create_autocmd
|
||||
bo = vim.bo
|
||||
wo = vim.wo
|
||||
|
||||
-- global options
|
||||
o.nu = true
|
||||
o.relativenumber = true
|
||||
o.hlsearch = false
|
||||
o.showcmd = true
|
||||
o.showmode = true
|
||||
o.splitright = true
|
||||
o.tabstop = 4
|
||||
o.softtabstop = 4
|
||||
o.shiftwidth = 4
|
||||
o.undofile = true
|
||||
o.swapfile = false
|
||||
o.backup = false
|
||||
o.ignorecase = true
|
||||
o.smartcase = true
|
||||
o.mouse = 'a'
|
||||
o.showtabline = 2
|
||||
o.laststatus = 0
|
||||
o.scrolloff = 8
|
||||
o.clipboard = 'unnamedplus'
|
||||
o.completeopt = 'menu', 'menuone', 'noselect'
|
||||
o.hlsearch = false
|
||||
o.ignorecase = true
|
||||
o.laststatus = 0
|
||||
o.list = true
|
||||
o.listchars = 'nbsp:¬,tab:»·,trail:·,extends:>'
|
||||
o.completeopt = 'menu', 'menuone', 'noselect'
|
||||
o.mouse = 'a'
|
||||
o.nu = true
|
||||
o.relativenumber = true
|
||||
o.scrolloff = 8
|
||||
o.shiftwidth = 4
|
||||
o.showcmd = true
|
||||
o.showmode = true
|
||||
o.showtabline = 2
|
||||
o.smartcase = true
|
||||
o.softtabstop = 4
|
||||
o.splitright = true
|
||||
o.swapfile = false
|
||||
o.tabstop = 4
|
||||
o.undofile = true
|
||||
|
||||
-- local options
|
||||
wo.wrap = false
|
||||
|
||||
-- fzf
|
||||
g.fzf_layout = { down = '30%' }
|
||||
|
||||
-- autocmds
|
||||
au({ 'BufWritePre' }, { pattern = { '*' }, command = [[%s/\n\+\%$//e]] })
|
||||
au({ 'FileType' }, { pattern = { '*' }, command = [[setlocal formatoptions-=cro]] })
|
||||
|
|
Loading…
Reference in a new issue