Configure for .stowrc
This commit is contained in:
parent
e58bb4c0a0
commit
1091129506
132 changed files with 4 additions and 18 deletions
11
slackware/home/nvim/.config/nvim/lua/config.lua
Normal file
11
slackware/home/nvim/.config/nvim/lua/config.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- require('keybindings')
|
||||
-- require('package')
|
||||
-- require('config')
|
||||
|
||||
-- Global options: vim.o
|
||||
-- Local to window: vim.wo
|
||||
-- Local to buffer: vim.bo
|
||||
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.softtabstop = 2
|
||||
199
slackware/home/nvim/.config/nvim/lua/init.lua
Normal file
199
slackware/home/nvim/.config/nvim/lua/init.lua
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
require('keybindings')
|
||||
require('packages')
|
||||
require('config')
|
||||
|
||||
-- Treesitter Confirg
|
||||
require('nvim-treesitter.configs').setup {
|
||||
ensure_installed = {
|
||||
"c", "lua", "rust", "python", "typescript", "bash", "clojure",
|
||||
"comment", "commonlisp", "fennel", "fish", "json", "html", "markdown",
|
||||
"make", "toml", "tsx", "vim", "yaml"
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
}
|
||||
}
|
||||
|
||||
-- LSP Language Installer
|
||||
local lsp_installer = require("nvim-lsp-installer")
|
||||
|
||||
-- Setup lspconfig.
|
||||
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.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', vim.lsp.buf.formatting, bufopts)
|
||||
end
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
lsp_installer.on_server_ready(function(server)
|
||||
local opts = {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
if server.name == "sumneko_lua" then
|
||||
opts.settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = {'vim', 'use'}
|
||||
},
|
||||
}
|
||||
}
|
||||
end
|
||||
server:setup(opts)
|
||||
end)
|
||||
|
||||
-- Needed for LuaSnip
|
||||
require("luasnip/loaders/from_vscode").lazy_load()
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
-- LSP Completion
|
||||
local cmp = require('cmp')
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
completion = { autocomplete = false },
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
-- ['<C-a>'] = cmp.mapping.complete(), -- use supertab
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), {'i','c'}),
|
||||
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), {'i','c'}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<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" }),
|
||||
}),
|
||||
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' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
||||
-- require('lspconfig').sumneko_lua.setup {
|
||||
-- on_attach = on_attach,
|
||||
-- capabilities = capabilities,
|
||||
-- }
|
||||
|
||||
-- require('lspconfig')['tsserver'].setup {
|
||||
-- capabilities = capabilities
|
||||
-- }
|
||||
-- require('lspconfig')['tsserver'].setup {
|
||||
-- capabilities = capabilities
|
||||
-- }
|
||||
|
||||
|
||||
|
||||
-- TODO figure out fold stuff later
|
||||
-- vim.opt.foldmethod = "expr"
|
||||
-- vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||
-- vim.opt.foldnestmax = 1
|
||||
vim.opt.completeopt = "menu" -- keep omnicomplete from spawning new buffer
|
||||
|
||||
-- Autoformatting
|
||||
require("formatter").setup {
|
||||
logging = false,
|
||||
log_level = vim.log.levels.WARN,
|
||||
filetype = {
|
||||
-- lua = {
|
||||
-- require("formatter.filetypes.lua").stylua,
|
||||
-- },
|
||||
python = {
|
||||
require("formatter.filetypes.python").black,
|
||||
},
|
||||
["*"] = {
|
||||
require("formatter.filetypes.any").remove_trailing_whitespace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- You will likely want to reduce updatetime which affects CursorHold
|
||||
-- note: this setting is global and should be set only once
|
||||
vim.o.updatetime = 250
|
||||
vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
|
||||
|
||||
|
||||
-- Base16 colors
|
||||
|
||||
-- start flavours
|
||||
require('base16-colorscheme').setup({
|
||||
base00 = '#e7e6df',
|
||||
base01 = '#929181',
|
||||
base02 = '#878573',
|
||||
base03 = '#6c6b5a',
|
||||
base04 = '#5f5e4e',
|
||||
base05 = '#302f27',
|
||||
base06 = '#22221b',
|
||||
base07 = '#ba6236',
|
||||
base08 = '#ae7313',
|
||||
base09 = '#a5980d',
|
||||
base0A = '#7d9726',
|
||||
base0B = '#5b9d48',
|
||||
base0C = '#36a166',
|
||||
base0D = '#5f9182',
|
||||
base0E = '#9d6c7c',
|
||||
base0F = '#{{base0G-hex}}'
|
||||
})
|
||||
-- end flavours
|
||||
24
slackware/home/nvim/.config/nvim/lua/keybindings.lua
Normal file
24
slackware/home/nvim/.config/nvim/lua/keybindings.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
-- vim.api.nvim_set_keymap({mode}, {keymap}, {mapped to}, {options})
|
||||
|
||||
local keymap = vim.api.nvim_set_keymap
|
||||
local opts = { noremap = true } -- don't recursively remap things
|
||||
|
||||
keymap('n', '?', ':tabNext<CR>', opts)
|
||||
-- keymap('n', 'gp', ':tabprevious<CR>', opts)
|
||||
|
||||
-- local function nkeymap(key, map)
|
||||
-- keymap('n', key, map, opts)
|
||||
-- end
|
||||
|
||||
-- nkeymap('gd', ':lua vim.lsp.buf.definition()<cr>')
|
||||
-- nkeymap('gD', ':lua vim.lsp.buf.declaration()<cr>')
|
||||
-- nkeymap('gi', ':lua vim.lsp.buf.implementation()<cr>')
|
||||
-- nkeymap('gw', ':lua vim.lsp.buf.document_symbol()<cr>')
|
||||
-- nkeymap('gw', ':lua vim.lsp.buf.workspace_symbol()<cr>')
|
||||
-- nkeymap('gr', ':lua vim.lsp.buf.references()<cr>')
|
||||
-- nkeymap('gt', ':lua vim.lsp.buf.type_definition()<cr>')
|
||||
-- nkeymap('K', ':lua vim.lsp.buf.hover()<cr>')
|
||||
-- nkeymap('<c-k>', ':lua vim.lsp.buf.signature_help()<cr>')
|
||||
-- nkeymap('<leader>af', ':lua vim.lsp.buf.code_action()<cr>')
|
||||
-- nkeymap('<leader>rn', ':lua vim.lsp.buf.rename()<cr>')
|
||||
|
||||
17
slackware/home/nvim/.config/nvim/lua/packages.lua
Normal file
17
slackware/home/nvim/.config/nvim/lua/packages.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
require('packer').startup(function()
|
||||
use 'wbthomason/packer.nvim'
|
||||
use 'nvim-treesitter/nvim-treesitter'
|
||||
use 'williamboman/nvim-lsp-installer'
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use 'hrsh7th/cmp-nvim-lsp'
|
||||
use 'hrsh7th/cmp-buffer'
|
||||
use 'hrsh7th/cmp-path'
|
||||
use 'hrsh7th/cmp-cmdline'
|
||||
use 'hrsh7th/nvim-cmp'
|
||||
use 'L3MON4D3/LuaSnip'
|
||||
use 'rafamadriz/friendly-snippets'
|
||||
use 'saadparwaiz1/cmp_luasnip'
|
||||
use 'onsails/lspkind-nvim'
|
||||
use 'mhartington/formatter.nvim'
|
||||
use 'RRethy/nvim-base16'
|
||||
end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue