Formatting

This commit is contained in:
Evie Litherland-Smith 2022-11-07 16:41:35 +00:00
parent 038e5af3b5
commit 3903e1486f
14 changed files with 76 additions and 80 deletions

View file

@ -1,6 +1,6 @@
-- Mappings. -- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions -- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true } local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts) vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, 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', ']d', vim.diagnostic.goto_next, opts)
@ -14,7 +14,7 @@ local on_attach = function(client, bufnr)
-- Mappings. -- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr } 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.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, 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', 'K', vim.lsp.buf.hover, bufopts)
@ -31,12 +31,12 @@ local on_attach = function(client, bufnr)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
-- Keep support for deprecated syntax in vim <= 7 -- Keep support for deprecated syntax in vim <= 7
if vim.version().minor <= 7 then if vim.version().minor <= 7 then
vim.keymap.set('n', '<leader>i', function () vim.keymap.set('n', '<leader>i', function()
vim.lsp.buf.formatting_sync({timeout_ms=10000}) vim.lsp.buf.formatting_sync({ timeout_ms = 10000 })
end, bufopts) end, bufopts)
else else
vim.keymap.set('n', '<leader>i', function () vim.keymap.set('n', '<leader>i', function()
vim.lsp.buf.format({timeout_ms=10000,async=false}) vim.lsp.buf.format({ timeout_ms = 10000, async = false })
end, bufopts) end, bufopts)
end end
-- Enable aerial support -- Enable aerial support
@ -49,7 +49,7 @@ local lsp_flags = {
} }
-- Setup nvim-cmp. -- Setup nvim-cmp.
local cmp = require'cmp' local cmp = require 'cmp'
cmp.setup({ cmp.setup({
snippet = { snippet = {
@ -114,30 +114,30 @@ cmp.setup.cmdline(':', {
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
local function file_exists(name) local function file_exists(name)
local f=io.open(name,"r") local f = io.open(name, "r")
if f~=nil then io.close(f) return true else return false end if f ~= nil then io.close(f) return true else return false end
end end
local pyright_file = os.getenv( "HOME" ).."/.pyenv/versions/neovim3/bin/pyright-langserver" local pyright_file = os.getenv("HOME") .. "/.pyenv/versions/neovim3/bin/pyright-langserver"
local pylsp_file = os.getenv( "HOME" ).."/.pyenv/versions/neovim3/bin/pylsp" local pylsp_file = os.getenv("HOME") .. "/.pyenv/versions/neovim3/bin/pylsp"
if file_exists(pyright_file) then if file_exists(pyright_file) then
require('lspconfig')['pyright'].setup{ require('lspconfig')['pyright'].setup {
cmd = {pyright_file, "--stdio"}, cmd = { pyright_file, "--stdio" },
on_attach = on_attach, on_attach = on_attach,
flags = lsp_flags, flags = lsp_flags,
capabilities = capabilities, capabilities = capabilities,
} }
elseif file_exists(pylsp_file) then elseif file_exists(pylsp_file) then
require('lspconfig')['pylsp'].setup{ require('lspconfig')['pylsp'].setup {
cmd = {pylsp_file}, cmd = { pylsp_file },
on_attach = on_attach, on_attach = on_attach,
flags = lsp_flags, flags = lsp_flags,
settings = { settings = {
pylsp = { pylsp = {
plugins = { plugins = {
pycodestyle = {maxLineLength = 88}, pycodestyle = { maxLineLength = 88 },
flake8 = {maxLineLength = 88} flake8 = { maxLineLength = 88 }
} }
} }
}, },
@ -145,21 +145,21 @@ elseif file_exists(pylsp_file) then
} }
end end
require('lspconfig')['efm'].setup{ require('lspconfig')['efm'].setup {
init_options = {documentFormatting = true}, init_options = { documentFormatting = true },
settings = { settings = {
languages = { languages = {
python = { python = {
{formatCommand = 'black --quiet -', formatStdin = true}, { formatCommand = 'black --quiet -', formatStdin = true },
{formatCommand = 'isort --quiet -', formatStdin = true}, { formatCommand = 'isort --quiet -', formatStdin = true },
}, },
}, },
}, },
filetypes = {'python'}, filetypes = { 'python' },
} }
require('lspconfig')['fortls'].setup{ require('lspconfig')['fortls'].setup {
cmd = {os.getenv( "HOME" ).."/.pyenv/versions/neovim3/bin/fortls"}, cmd = { os.getenv("HOME") .. "/.pyenv/versions/neovim3/bin/fortls" },
on_attach = on_attach, on_attach = on_attach,
flags = lsp_flags, flags = lsp_flags,
capabilities = capabilities capabilities = capabilities
@ -174,7 +174,7 @@ require('lspconfig')['sumneko_lua'].setup {
}, },
diagnostics = { diagnostics = {
-- Get the language server to recognize the `vim` global -- Get the language server to recognize the `vim` global
globals = {'vim'}, globals = { 'vim' },
}, },
workspace = { workspace = {
-- Make the server aware of Neovim runtime files -- Make the server aware of Neovim runtime files

View file

@ -1,4 +1,4 @@
require('aerial').setup{ require('aerial').setup {
on_attach = function(bufnr) on_attach = function(bufnr)
-- Toggle the aerial window with <leader>a -- Toggle the aerial window with <leader>a
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>k', '<cmd>AerialToggle!<CR>', {}) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>k', '<cmd>AerialToggle!<CR>', {})
@ -10,4 +10,3 @@ require('aerial').setup{
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']]', '<cmd>AerialNextUp<CR>', {}) vim.api.nvim_buf_set_keymap(bufnr, 'n', ']]', '<cmd>AerialNextUp<CR>', {})
end, end,
} }

View file

@ -1,4 +1,4 @@
require('gitsigns').setup{ require('gitsigns').setup {
signcolumn = true, signcolumn = true,
numhl = true, numhl = true,
linehl = true, linehl = true,

View file

@ -1,11 +1,11 @@
require('lualine').setup{ require('lualine').setup {
options = { options = {
icons_enabled = true, icons_enabled = true,
theme = 'auto', theme = 'auto',
}, },
sections = { sections = {
-- lualine_x = {'encoding', 'fileformat', 'filetype'}, -- lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_x = {'aerial', 'filetype'} lualine_x = { 'aerial', 'filetype' }
}, },
extensions = {'aerial', 'fugitive', 'fzf', 'nvim-tree', 'toggleterm'} extensions = { 'aerial', 'fugitive', 'fzf', 'nvim-tree', 'toggleterm' }
} }

View file

@ -1,5 +1,5 @@
vim.opt.termguicolors=true vim.opt.termguicolors = true
require('nightfox').setup{ require('nightfox').setup {
modules = { modules = {
aerial = true, aerial = true,
cmp = true, cmp = true,

View file

@ -1,6 +1,6 @@
vim.g.loaded = 1 vim.g.loaded = 1
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1
require('nvim-tree').setup{ require('nvim-tree').setup {
filters = { custom = { "^.git$" } }, filters = { custom = { "^.git$" } },
renderer = { renderer = {
group_empty = true, group_empty = true,

View file

@ -1,6 +1,6 @@
require('sniprun').setup{ require('sniprun').setup {
selected_interpreters = { 'Python3_fifo' }, selected_interpreters = { 'Python3_fifo' },
repl_enable = {'Python3_fifo'}, repl_enable = { 'Python3_fifo' },
display = { display = {
"NvimNotify" "NvimNotify"
}, },

View file

@ -1,10 +1,10 @@
require('telescope').load_extension('aerial') require('telescope').load_extension('aerial')
require('telescope').load_extension('notify') require('telescope').load_extension('notify')
local actions = require('telescope.actions') require('telescope.actions')
local trouble = require('trouble.providers.telescope') local trouble = require('trouble.providers.telescope')
require('telescope').setup{ require('telescope').setup {
defaults = { defaults = {
mappings = { mappings = {
i = { ["<c-t>"] = trouble.open_with_trouble }, i = { ["<c-t>"] = trouble.open_with_trouble },

View file

@ -1,4 +1,4 @@
require('toggleterm').setup{ require('toggleterm').setup {
direction = 'float', direction = 'float',
open_mapping = [[\t]], open_mapping = [[\t]],
size = 20, size = 20,
@ -7,7 +7,7 @@ require('toggleterm').setup{
} }
function _G.set_terminal_keymaps() function _G.set_terminal_keymaps()
local opts = {buffer = 0} local opts = { buffer = 0 }
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts) vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts) vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts) vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)

View file

@ -1,9 +1,8 @@
require'nvim-treesitter.configs'.setup { require 'nvim-treesitter.configs'.setup {
ensure_installed = { "python" }, ensure_installed = { "python" },
highlight = { highlight = {
enable = true, enable = true,
additional_vim_regex_highlighting = false, additional_vim_regex_highlighting = false,
disable = {'help'}, disable = { 'help' },
}, },
} }

View file

@ -10,9 +10,9 @@ local function imap(shortcut, command)
map('i', shortcut, command) map('i', shortcut, command)
end end
vim.g.mapleader=' ' vim.g.mapleader = ' '
-- Misc -- Misc
imap('jk','<Esc>') imap('jk', '<Esc>')
nmap('<leader>sr', ':SnipRun<cr>') nmap('<leader>sr', ':SnipRun<cr>')
nmap('<leader>gf', ':Git fetch<cr>') nmap('<leader>gf', ':Git fetch<cr>')
nmap('<leader>gp', ':Git pull<cr>') nmap('<leader>gp', ':Git pull<cr>')

View file

@ -5,18 +5,17 @@ vim.g.python_indent = {
continue = 'shiftwidth()', continue = 'shiftwidth()',
closed_paren_align_last_line = 'v:false', closed_paren_align_last_line = 'v:false',
} }
vim.opt.mouse="nv" vim.opt.mouse = "nv"
vim.opt.shiftwidth=4 vim.opt.shiftwidth = 4
vim.opt.number=true vim.opt.number = true
vim.opt.relativenumber=true vim.opt.relativenumber = true
vim.opt.listchars = {trail = '.', tab = '>_'} vim.opt.listchars = { trail = '.', tab = '>_' }
vim.opt.list=true vim.opt.list = true
vim.opt.wrap=true vim.opt.wrap = true
vim.opt.linebreak=true vim.opt.linebreak = true
vim.opt.autoread=true vim.opt.autoread = true
vim.opt.expandtab=true vim.opt.expandtab = true
vim.opt.autoindent=true vim.opt.autoindent = true
vim.opt.smartindent=true vim.opt.smartindent = true
vim.opt.splitbelow=true vim.opt.splitbelow = true
vim.opt.splitright=true vim.opt.splitright = true

View file

@ -10,7 +10,7 @@ require('packer').startup {
use 'wbthomason/packer.nvim' use 'wbthomason/packer.nvim'
use { use {
'rcarriga/nvim-notify', 'rcarriga/nvim-notify',
config = function () config = function()
vim.notify = require("notify") vim.notify = require("notify")
end end
} }
@ -28,45 +28,45 @@ require('packer').startup {
use 'hrsh7th/vim-vsnip' use 'hrsh7th/vim-vsnip'
use { use {
'EdenEast/nightfox.nvim', 'EdenEast/nightfox.nvim',
config = function () config = function()
require 'config_plugins.config_nightfox' require 'config_plugins.config_nightfox'
end end
} }
use { use {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate', run = ':TSUpdate',
config = function () config = function()
require 'config_plugins.config_treesitter' require 'config_plugins.config_treesitter'
end end
} }
use { use {
'j-hui/fidget.nvim', 'j-hui/fidget.nvim',
config = function () config = function()
require('fidget').setup() require('fidget').setup()
end end
} }
use { use {
'stevearc/aerial.nvim', 'stevearc/aerial.nvim',
branch = 'nvim-0.5', branch = 'nvim-0.5',
config = function () config = function()
require 'config_plugins.config_aerial' require 'config_plugins.config_aerial'
end end
} }
use { use {
'tpope/vim-fugitive', 'tpope/vim-fugitive',
opt = true, opt = true,
cmd = {'G', 'Git'} cmd = { 'G', 'Git' }
} }
use { use {
'https://github.com/lewis6991/gitsigns.nvim.git', 'https://github.com/lewis6991/gitsigns.nvim.git',
tag = 'release', tag = 'release',
config = function () config = function()
require 'config_plugins.config_gitsigns' require 'config_plugins.config_gitsigns'
end end
} }
use { use {
'nvim-lualine/lualine.nvim', 'nvim-lualine/lualine.nvim',
config = function () config = function()
require 'config_plugins.config_lualine' require 'config_plugins.config_lualine'
end end
} }
@ -79,7 +79,7 @@ require('packer').startup {
use { use {
'akinsho/toggleterm.nvim', 'akinsho/toggleterm.nvim',
tag = 'v2.*', tag = 'v2.*',
config = function () config = function()
require 'config_plugins.config_toggleterm' require 'config_plugins.config_toggleterm'
end end
} }
@ -87,9 +87,9 @@ require('packer').startup {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
branch = '0.1.x', branch = '0.1.x',
requires = { requires = {
{'nvim-lua/plenary.nvim'} { 'nvim-lua/plenary.nvim' }
}, },
config = function () config = function()
require 'config_plugins.config_telescope' require 'config_plugins.config_telescope'
end end
} }
@ -101,33 +101,33 @@ require('packer').startup {
'michaelb/sniprun', 'michaelb/sniprun',
run = 'bash install.sh', run = 'bash install.sh',
opt = true, opt = true,
cmd = {'SnipRun', 'SnipInfo', 'SnipReset'}, cmd = { 'SnipRun', 'SnipInfo', 'SnipReset' },
config = function () config = function()
require 'config_plugins.config_sniprun' require 'config_plugins.config_sniprun'
end end
} }
use { use {
'phaazon/hop.nvim', 'phaazon/hop.nvim',
config = function () config = function()
require('hop').setup() require('hop').setup()
end end
} }
use { use {
'folke/trouble.nvim', 'folke/trouble.nvim',
config = function () config = function()
require('trouble').setup() require('trouble').setup()
end end
} }
use { use {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
config = function () config = function()
require('indent_blankline').setup() require('indent_blankline').setup()
end end
} }
end, end,
config = { config = {
display = { display = {
open_fn = function () open_fn = function()
return require('packer.util').float({ border = 'single' }) return require('packer.util').float({ border = 'single' })
end end
}, },

View file

@ -1,6 +1,6 @@
-- TODO convert to lua -- TODO convert to lua
vim.cmd("let &t_ut=''") -- For kitty background colour support vim.cmd("let &t_ut=''") -- For kitty background colour support
vim.cmd[[ vim.cmd [[
au BufRead,BufNewFile *.ipynb setlocal filetype=json au BufRead,BufNewFile *.ipynb setlocal filetype=json
au BufRead,BufNewFile *.md setlocal spell au BufRead,BufNewFile *.md setlocal spell
au BufRead,BufNewFile *.code-workspace setlocal filetype=json au BufRead,BufNewFile *.code-workspace setlocal filetype=json
@ -9,4 +9,3 @@ au BufRead,BufNewFile *.service[a-zA-Z0-9]* setlocal filetype=systemd
au TermOpen * setlocal nonumber norelativenumber au TermOpen * setlocal nonumber norelativenumber
syntax on syntax on
]] ]]